
********************************************************************************
********************************************************************************

							* DIRECTOR SURVEY *

********************************************************************************
********************************************************************************

use "$Endline_dtRaw/director/Questionrio 3 - Diretor.dta", clear

label drop _all

********************************************************************************

// Identification cleaning, apply to all rosters!

drop if inlist(interview__key,"29-35-82-40","45-38-73-05","24-37-82-64")

********************************************************************************

replace school_id = 30 if interview__key == "45-60-51-52"
replace school_id = 57 if interview__key == "22-88-69-77"
replace resp_id = 1 if interview__key == "16-77-72-24"
replace resp_id = 2 if interview__key == "75-93-45-27"

// Identification variable for game played

gen game = .

replace game = 1 if inlist(interview__key,"45-60-51-52","43-44-84-92","03-92-30-14","48-07-21-97","95-96-96-73","31-79-44-75","94-00-37-46","38-14-33-35","27-74-15-88")
replace game = 1 if inlist(interview__key,"73-90-67-70","63-87-37-95","43-51-43-71","66-68-81-00","41-42-10-45","31-21-00-56","89-01-13-83","36-15-10-46","18-61-70-85")

lab var game "Director played game"

********************************************************************************

// Identification variables for matching

gen survey_type = 3

gen teacher_id2 = 100*school_id + 88

********************************************************************************

* Survey solutions variables

order interview__key interview__id sssys_irnd has__errors

drop interview__status

label variable interview__id "Unique 32-character long identifier"
label variable interview__key "Interview key (XX-XX-XX-XX format)"
label variable sssys_irnd "Random number range 0..1 associated with interview"
label variable has__errors "Errors count in the interview"

rename interview__id 	ss_id
rename interview__key 	ss_key
rename sssys_irnd 		ss_random
rename has__errors 		ss_errors

drop consensus

// add municipality and treatment variable to data set

gen municipality = .

replace municipality = 1 if inlist(school_id,1,2,3,4,5,6,7,8,9,10,12,13,	///
	14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,31,32,33,34,35,37,		///
	40,45,61,86,110)

replace municipality = 2 if inlist(school_id,23,43,44,46,47,48,49,50,51,	///
	52,53,54,55,56,57,58,59,60,62,63,64,65,66,67,68,69,70,71,72,73,75,76,	///
	77,78,79,80,81)

replace municipality = 3 if inlist(school_id,11,36,38,39,41,42,74,82,83,84,	///
	85,87,88,89,90,91,92,93,94,95,96,97,98,99,101,102,103,104,105)

replace municipality = 4 if inlist(school_id,118,119,120,121,122,123,124,125)
replace municipality = 5 if inlist(school_id,100,112,113,114,115,116,117)
replace municipality = 6 if inlist(school_id,109,111)
replace municipality = 7 if inlist(school_id,106,107)
replace municipality = 8 if inlist(school_id,126)
replace municipality = 9 if inlist(school_id,108)

gen treatment = .

replace treatment = 0 if inlist(school_id,3,4,7,10,16,18,20,23,26,29,33, ///
	39,42,53,55,62,63,64,65,78,81,84,87,88,89,92,98,108,109,116,117,121)

replace treatment = 1 if inlist(school_id,15,19,22,27,32,36,37,40,49,51, ///
	56,57,58,61,66,68,72,76,79,82,83,86,91,95,100,102,103,106,110,114,125,126)

replace treatment = 2 if inlist(school_id,1,5,6,11,12,14,21,24,25,31,41, ///
	48,50,52,59,70,73,77,80,90,93,94,101,105,107,111,112,113,119,120,124)

replace treatment = 3 if inlist(school_id,2,8,9,13,17,28,30,34,35,38,43, ///
	44,45,46,47,54,60,67,69,71,74,75,85,96,97,99,104,115,118,122,123)

********************************************************************************

order 	teacher_id2 survey_type game school_id resp_id municipality treatment 		///
		supervisor interviewer date_time_start date_time_end, after(ss_errors)

********************************************************************************

// labelssss

#delimit ;
;
label define treatment
0	"Control group"
1	"Door-to-door"
2	"Meetings"
3	"Both treatments"
;
label define municipality
1	"Sumbe"
2	"Porto Amboim"
3	"Gabela"
4	"Conda"
5	"Ebo"
6	"Quilenda"
7	"Seles"
8	"Cassongue"
9	"Quibala"
;
label define enum
1	"Antonio Lopes Miguel Rocha"
2	"Augusta Júlio Miranda"
3	"César Zau Joaquim Morais Mendes"
4	"Edesdeth Abrantes Fonseca"
5	"Fernando Portugal Leonardo"
6	"Filipe Quissana Cariengue"
7	"Herlander Mauro Lemos Lima"
8	"Manuel Aguinaldo Barroso Moreira Francisco"
9	"Albertina de Oliveira Armando"
10	"Augusto Viana Kupinga"
11	"Beatriz Laurinda Teixeira da Costa"
12	"Carlos da Fonseca Ricardo "
13	"Carolina Germano da Silva"
14	"Felizarda Luis Avelino"
15	"Hermínia Caetano Kalolo"
16	"Ilídio Duarte Reis Cardoso"
17	"Isabel Marcolino Lisboa"
18	"João Monteiro Bimbe"
19	"José Alberto Nungulo Kamucunja"
20	"Manuel Pinheiro Inacio Ernesto"
21	"Marimilia Francisco Fernando"
22	"José Bambi Kandjeke"
23	"Samora Paulo José Ganga"
24	"Victória Maneco Tavares"
25	"Adelaide Fernando Miguens"
26	"Adelaide Marcelina da Cruz Zeferino"
27	"Adilson Fragoso Pascoal Inácio Filipe"
28	"Amaro Alberto Chipa"
29	"Ana Paula Silvestre Ventura"
30	"Antonio Calei Pedro da Silva"
31	"António Manuel da Silva"
32	"Bernardo Miguêns Gimbo"
33	"Bernardo Sungo Manuel Zau"
34	"Bráulio Eanes Gabriel Alberto"
35	"Bruno José Fernando Viegas"
36	"Carvalinho António Correia"
37	"Cirineu Jr. Jorge"
38	"Domingos Guimarães Sumano"
39	"Elvino António Sobral Salomão"
40	"Etelvina Albertina Francisco Teixeira"
41	"Helder Silvestre Lino Tomé Pinto"
42	"Joana Pinto Soma"
43	"Jonas Frederico Albino Rangel"
44	"José Catraio António"
45	"José Luciano Januário"
46	"José Maria Sumano Delgado"
47	"José Pinto Fançony"
48	"Magalhães Salissinga Gomes"
49	"Maria de Fátima Paulo Feliciano"
50	"Mariza Fernando Manuel Vales"
51	"Monteiro Bastos"
52	"Nilton Januário Valentim"
53	"Sara Claúdio Vidro Aguiar Maneco"
54	"Telma da Conceição Mweleyavo António"
55	"Teresa Aguiar da Costa"
56	"Teresa Kizua Kassucada"
57	"Bruno Avelino Segunda"
58	"Inocêncio Mário Cupenala"
59	"Sabino Jorge Bira"
;
label define resp_pos
1 `"Director"'
2 `"Deputy director"'
3 `"Acting director"'
;
label define dummy
0	"No"
1 	"Yes"
;
label define survey_type
1	"Parent"
2	"Teacher"
3	"Director"
;
label define female
0 `"Male"'
1 `"Female"'
;
label define edu
0 `"No education"'
1 `"First grade"'
2 `"Primary school 1 (grades 1-4)"'
3 `"Primary school 2 (grades 5-6)"'
4 `"Secondary school 1 (grades 7-8) terceiro nivel"'
5 `"Secondary school 2 (grades 9-12) - ensino medio"'
6 `"Technical and Vocational Education (2-4 years)"'
7 `"Goes to university"'
8 `"Bacharel - Angola"'
9 `"Bachelor - Angola"'
10 `"Master - Angola"'
11 `"University - abroad"'
;
label define ocu
1 `"Part-time job in private sector"'
2 `"Part-time job in public sector"'
3 `"Full-time job in private sector"'
4 `"Full-time job in public sector"'
5 `"Self-employed"'
6 `"Business owner, employs other people"'
7 `"Farmer works with the family"'
8 `"Farmer, employs other people"'
9 `"Fisherman"'
10 `"Religious work"'
11 `"Retired"'
12 `"Student"'
13 `"Housewife"'
14 `"Unemployed"'
15 "Local leader or elected official"
16 "Shepherd"
17 "Voluntary teacher"
;
label define residence_loc
1 `"School neighborhood"'
2 `"Other neighborbood in school municipality"'
3 `"Outside of the school municipality"'
;
label define marital
1 `"Maried"'
2 `"Live together"'
3 `"Single"'
4 `"Widow"'
5 `"Divorced"'
;
label define residence_own
1 `"Property"'
2 `"Rented"'
3 `"Made available by family"'
4 `"Made available by community"'
5 `"Made available by state"'
6 `"Lives with parents"'
;
label define income
1 `"Less than 5 000 AKZ/month"'
2 `"5 001 - 10 000 AKZ/month"'
3 `"10 001 - 25 000 AKZ/month"'
4 `"25 001 - 50 000 AKZ/month"'
5 `"50 001 - 100 000 AKZ/month"'
6 `"100 001 - 150 000 AKZ/month"'
7 `"150 001 - 200 000 AKZ/month"'
8 `"More than 200 001 AKZ/month"'
;
label define language
1 `"Portugues"'
2 `"Umbundu"'
3 `"Kimbundu"'
4 `"Kicongo"'
5 `"Ngoia"'
6 "Ngangula"
7 "Hele"
;
label define transportation
1 `"By foot"'
2 `"Hitchhike"'
3 `"Bicycle"'
4 `"Minivan taxi"'
5 `"Bike taxi"'
6 `"Own bike"'
7 `"Own car"'
8 `"Rented bike"'
;
label define distance_home
1 `"Less than 500 meters"'
2 `"501 meters - 1 km"'
3 `"1 - 5 km"'
4 `"6 - 10 km"'
5 `"10 - 20 km"'
6 `"More than 20 km"'
;
#delimit cr

********************************************************************************

label values supervisor interviewer enum
label values municipality municipality
label values treatment treatment
label values resp_teach dummy
label values survey_type survey_type

label variable date_time_start `"Date and time start interview"'
label variable date_time_end `"Date and time end interview"'
label variable school_id `"ID number school"'
label variable municipality "Municipality"
label variable treatment "Treatment group"
label variable resp_id `"ID number respondent"'
label variable supervisor `"Supervisor"'
label variable interviewer `"Interviewer"'
label variable resp_name `"Name respondent"'
label variable resp_tel `"Phone number respondent"'
label variable resp_pos `"Position of respondent at the school"'
label variable resp_teach `"Respondent also teaches"'
label variable teacher_id2 `"Identification for merge with games"'
label variable survey_type `"Survey type"'

label variable resp_grade__0 `"Teacher of pre-school classes"'
label variable resp_grade__1 `"Teacher of grade 1 classes"'
label variable resp_grade__2 `"Teacher of grade 2 classes"'
label variable resp_grade__3 `"Teacher of grade 3 classes"'
label variable resp_grade__4 `"Teacher of grade 4 classes"'
label variable resp_grade__5 `"Teacher of grade 5 classes"'
label variable resp_grade__6 `"Teacher of grade 6 classes"'
label variable resp_grade__7 `"Teacher of grade 7 classes"'
label variable resp_grade__8 `"Teacher of grade 8 classes"'
label variable resp_grade__9 `"Teacher of grade 9 classes"'
label variable resp_grade__11 `"Teacher of module 1 classes (grades 1 and 2)"'
label variable resp_grade__22 `"Teacher of module 2 classes (grades 3 and 4)"'
label variable resp_grade__33 `"Teacher of module 3 classes (grades 5 and 6)"'

********************************************************************************


********************************************************************************

* Section 1

drop 	aor aorcap senhor diretor aas ees aam estaestao vaivao mais outros 	///
		D01_09__1 D01_09__2 D01_09_other turma1

label variable D01_01 `"Age respondent"'
label variable D01_02 `"Gender respondent"'
lab val D01_02 female
label values D01_03 residence_loc
label variable D01_03 `"Current home neighbourhood relative to the school"'

label variable D01_03_other2 `"Other current home neighbourhood if in same municipality as school"'
label variable D01_03_other3 `"Current home municipality if not in same municipality as school"'

label values D01_04 residence_loc
label variable D01_04 `"Birthplace relative to the school"'

label variable D01_04_other2 `"Other birthplace (neighbourhood) if in same municipality as school"'
label variable D01_04_other3 `"Birthplace (municipality) if not in same municipality as school"'

label variable D01_05 `"Years of living in current neighbourhood"'

label values D01_06 edu

label variable D01_06 `"Highest level of education enjoyed by respondent"'
label variable D01_07 `"Years of university"'
label variable D01_08__1 `"Director studied education"'
label variable D01_08_other "[Specified] Director studied social or formal/applied science"
label values D01_10 dummy
label variable D01_10 `"Teaching is main profession"'
label values D01_11 ocu
label variable D01_11 `"Occupation respondent"'
label values D01_12 marital
label variable D01_12 `"Marital status respondent"'
label values D01_13 edu
label variable D01_13 `"Highest level of education enjoyed by partner respondent"'
label values D01_14 ocu
label variable D01_14 `"Occupation partner respondent"'
label values D01_15 residence_own
label variable D01_15 `"Type of home in terms of ownership"'
label values D01_16 income
label variable D01_16 `"Monthly total home income"'
label variable D01_17 `"How many of your children live with you?"'
label variable D01_18 `"How many children live with you but are not your children?"'
label variable D01_19 `"How many of the children that live with you are girls?"'
label variable D01_20 `"How many of the children living in your home attend this elementary school"'
label variable D01_21__0 `"Has children in pre-school"'
label variable D01_21__1 `"Has children in grade 1"'
label variable D01_21__2 `"Has children in grade 2"'
label variable D01_21__3 `"Has children in grade 3"'
label variable D01_21__4 `"Has children in grade 4"'
label variable D01_21__5 `"Has children in grade 5"'
label variable D01_21__6 `"Has children in grade 6"'
label variable D01_21__7 `"Has children in grade 7"'
label variable D01_21__8 `"Has children in grade 8"'
label variable D01_21__9 `"Has children in grade 9"'
label values D01_22 language
label variable D01_22 `"Language spoken at home"'
label values D01_23 transportation
label variable D01_23 `"Method of transportation used by respondent between home and school"'
label variable D01_24 `"Time in minutes spend by respondent between home and school"'
label values D01_25 distance_home
label variable D01_25 `"Aproximate distance in km between home and school"'

replace D01_06 = 5 if D01_08_other=="Ensino Medio Normal"

replace D01_07 = . if D01_06==8

rename D01_08__2 D01_08__2_old

gen D01_08__2 = 0 if D01_08__1!=.
gen D01_08__3 = 0 if D01_08__1!=.
gen D01_08__4 = 0 if D01_08__1!=.

label variable D01_08__2 `"Director studied pedagogia"'
label variable D01_08__3 `"Director studied a social science"'
label variable D01_08__4 `"Director studied a formal/applied science"'

order D01_08__2 D01_08__3 D01_08__4, after(D01_08__1)

replace D01_08__1 = 1 if D01_08_other=="Formação de Professor Primário"
replace D01_08__2 = 1 if D01_08_other=="Pedagigia"
replace D01_08__2 = 1 if D01_08_other=="Pedagogia"
replace D01_08__3 = 1 if D01_08_other=="Ciências Socias"
replace D01_08__3 = 1 if D01_08_other=="contabilidade e gestão"
replace D01_08__3 = 1 if D01_08_other=="Geografia"
replace D01_08__3 = 1 if D01_08_other=="Geografia/História"
replace D01_08__4 = 1 if D01_08_other=="Informática"

replace D01_11 = 5 if D01_11==15
replace D01_14 = 5 if D01_14==15
replace D01_15 = 4 if D01_15==6
replace D01_16 = . if D01_16==999

lab val D01_21__0 D01_21__1 D01_21__2 D01_21__3 D01_21__4 D01_21__5 	///
		D01_21__6 D01_21__7 D01_21__8 D01_21__9 dummy

drop D01_08__2_old D01_11_other D01_14_other D01_15_other D01_22_other

********************************************************************************

********************************************************************************

* Section 2 (teachers section 2)

// labelssss

#delimit ;
;
label define D02_15
1 `"Director"'
2 `"Deputy director"'
3 `"School board"'
4 `"Provincial board"'
5 `"Municipal/comunal board"'
6 `"Ministry of education"'
7 `"Task force / evaluation committee"'
;
label define D02_20
1 `"Teach at other public school"'
2 `"Teach at private school"'
3 `"Paid private classes"'
4 `"Business"'
5 `"Farming"'
6 `"Fishing"'
7 `"Other non-farming job"'
;
#delimit cr

label values D02_01 dummy
label variable D02_01 `"Did workshop about school management"'

label variable D02_02__1 `"Professional development: Did training in management"'
label variable D02_02__2 `"Professional development: Did university course on education"'
label variable D02_02__3 `"Professional development: Visited other schools"'
label variable D02_02__4 `"Professional development: Received help from other directors"'
label variable D02_02__5 `"Professional development: Participated in a teachers network"'
label variable D02_02__6 `"Professional development: Participated in a workshop or conference"'

replace D02_02__6 = 1 if D02_02__7==1

drop D02_02__0 D02_02__7 D02_02_other

lab val D02_02__1 D02_02__2 D02_02__3 D02_02__4 D02_02__5 D02_02__6 dummy

recode D02_03(2=0)
label values D02_03 dummy
label variable D02_03 `"Respondent became director before coming to this school"'

label variable D02_04 `"Years (sub)director at other schools"'
label variable D02_05 `"Years (sub)director at this school"'

label values D02_06 dummy

label variable D02_06 `"Used to teach at this school"'
label variable D02_07 `"Years teacher at the school before stopping"'
label variable D02_08 `"Years teaching at this school"'

label values D02_09 dummy
label variable D02_09 `"Taught at other school before this school"'
label variable D02_10 `"Years teaching at this school"'
label variable D02_11 `"Monthly salary"'
label values D02_12 dummy
label variable D02_12 `"Possible bonus"'
label values D02_13 dummy
label variable D02_13 `"Received bonus last year"'

foreach var in D02_04 D02_05 D02_07 D02_08 D02_10 D02_11 D02_12 {
replace `var' = . if `var'==999
}

replace D02_11 = . if D02_11==5762020


label variable D02_14__1 `"Performance is measured by student results"'
label variable D02_14__2 `"Performance is measured by level of preparation (teaching plan)"'
label variable D02_14__3 `"Performance is measured by absentism teachers"'
label variable D02_14__4 `"Performance is measured by student results in standardized tests"'
label variable D02_14__5 `"Performance is measured by class observations (by inspector)"'
label variable D02_14__6 `"Performance is measured by absentism students"'
label variable D02_14__7 `"Performance is measured by satisfaction of parents"'
label variable D02_14__8 `"Performance is measured by evaluation of an inspector"'
label variable D02_14__9 `"Performance is measured by fulfillment of activity plans"'
label variable D02_14__10 `"Performance is measured by the organization of records"'

drop D02_14__11
gen D02_14__11 = 0 if D02_14__1!=.
gen D02_14__12 = 0 if D02_14__1!=.
order D02_14__11 D02_14__12, after(D02_14__10)
label variable D02_14__11 `"Performance is measured by an evaluation form"'
label variable D02_14__12 `"Performance is measured by behavior and commitment"'

replace D02_14__3 = 1 if D02_14_other=="assiduidade da directora"
replace D02_14__9 = 1 if D02_14_other=="avaliação do desempenhou"
replace D02_14__9 = 1 if D02_14_other=="em função das actividades que se realiza"
replace D02_14__9 = 1 if D02_14_other=="Entrega a tempo dos expediente aos órgãos tutelar"
replace D02_14__9 = 1 if D02_14_other=="participação activa nas actividades da repartição"
replace D02_14__9 = 1 if D02_14_other=="participação de reuniões"
replace D02_14__9 = 1 if D02_14_other=="qualidades de trabalho, espirito de inicistivs, apreciação geral"
replace D02_14__10 = 1 if D02_14_other=="Organização da escola, Relação entre colegas"
replace D02_14__11 = 1 if D02_14_other=="atravez da fixa de avaliação do desempenho anual"
replace D02_14__12 = 1 if D02_14_other=="pela dinâmica emplimentada"
replace D02_14__12 = 1 if D02_14_other=="Organização da escola, Relação entre colegas"
replace D02_14__12 = 1 if D02_14_other=="comportamento"
replace D02_14__12 = 1 if D02_14_other=="Relacionamento entre colegas"

lab val D02_14__1 D02_14__2 D02_14__3 D02_14__4 D02_14__5 D02_14__6 		///
		D02_14__7 D02_14__8 D02_14__9 D02_14__10 D02_14__11 D02_14__12 dummy

drop D02_14__0 D02_14__999 D02_14_other

label values D02_15 D02_15
label variable D02_15 `"Responsible for evaluation"'

replace D02_15 = . if D02_15==999
replace D02_15 = . if D02_15==8

replace D02_15 = 5 if D02_15_other=="repartição municipal"
replace D02_15 = 5 if D02_15_other=="Repartição Municipal da Educação"
replace D02_15 = 5 if D02_15_other=="coordenador de zona"
replace D02_15 = 5 if D02_15_other=="Director de zona"
replace D02_15 = 7 if D02_15_other=="Comissão de Avaliação"
replace D02_15 = 7 if D02_15_other=="Comissão de avaliação anual da escola"
replace D02_15 = 7 if D02_15_other=="Núcleo de Avaliação Pedagógica (NAP)"

drop D02_15_other

label variable D02_16__1 `"Result of good performance: Financial bonus"'
label variable D02_16__2 `"Result of good performance: Trophy"'
label variable D02_16__3 `"Result of good performance: Promotion"'
label variable D02_16__4 `"Result of good performance: Transfer to better school"'
label variable D02_16__5 `"Result of good performance: Written or oral notification"'

replace D02_16__1 = 1 if D02_16_other=="Em função das condições do governo ganha um bónus"
replace D02_16__3 = 1 if D02_16_other=="mudança de categoria"
replace D02_16__5 = 1 if D02_16_other=="Elogio"

drop D02_16__0 D02_16__6 D02_16__999 D02_16_other

lab val D02_16__1 D02_16__2 D02_16__3 D02_16__4 D02_16__5 dummy

label variable D02_17__1 `"Result of bad performance: Financial sanction"'
label variable D02_17__2 `"Result of bad performance: Transfer"'
label variable D02_17__3 `"Result of bad performance: Dismissal"'
label variable D02_17__4 `"Result of bad performance: Written or oral notification"'

drop D02_17__5
gen D02_17__5 = 0 if D02_17__1!=.
gen D02_17__6 = 0 if D02_17__1!=.
label variable D02_17__5 `"Result of bad performance: Demotion"'
label variable D02_17__6 `"Result of bad performance: Lose chance on promotion/transfer"'
order D02_17__5 D02_17__6, after(D02_17__4)


replace D02_17__4 = 1 if D02_17_other=="Ma classificação"
replace D02_17__5 = 1 if D02_17_other=="Baixariam-me de categoria"
replace D02_17__5 = 1 if D02_17_other=="Despromovido"
replace D02_17__5 = 1 if D02_17_other=="Despromovido do cargo de Director"
replace D02_17__5 = 1 if D02_17_other=="Desqualificação"
replace D02_17__5 = 1 if D02_17_other=="É afastado do cargo"
replace D02_17__5 = 1 if D02_17_other=="Exoneração"
replace D02_17__5 = 1 if D02_17_other=="exoneração"
replace D02_17__5 = 1 if D02_17_other=="exoneração"
replace D02_17__5 = 1 if D02_17_other=="Exoneração"
replace D02_17__5 = 1 if D02_17_other=="pode ser isonerado"
replace D02_17__6 = 1 if D02_17_other=="não da acesso a promoção de outros cargos"
replace D02_17__6 = 1 if D02_17_other=="não são promovido  ou transferido caso o prof quiser"
replace D02_17__6 = 1 if D02_17_other=="nunca muda de categoria"

drop D02_17__0 D02_17__999 D02_17_other

label variable D02_18__1 `"Receives additional help from community or school: Yes, transportation"'
label variable D02_18__2 `"Receives additional help from community or school: Yes, food allowance"'
label variable D02_18__3 `"Receives additional help from community or school: Yes, place to sleep"'

lab val D02_18__1 D02_18__2 D02_18__3 dummy

drop D02_18__0 D02_18__4 D02_18__999 D02_18_other

label values D02_19 dummy
label variable D02_19 `"Respondent has other income"'

label values D02_20 D02_20
label variable D02_20 `"Source other income source"'

replace D02_20 = 4 if D02_20_other=="moagem"
replace D02_20 = 5 if D02_20_other=="agropecuária"
replace D02_20 = 5 if D02_20_other=="criação de gado"
replace D02_20 = 5 if D02_20_other=="Criador De Gado"

drop D02_20_other

label variable D02_21 `"Amount other income"'
replace D02_21=. if D02_21==999

********************************************************************************

********************************************************************************

* Section 3 (teacher section 3)

// labelssss

#delimit ;
;
label define grade
0 `"Pre-school"'
1 `"Grade 1"'
2 `"Grade 2"'
3 `"Grade 3"'
4 `"Grade 4"'
5 `"Grade 5"'
6 `"Grade 6"'
7 `"Grade 7"'
8 `"Grade 8"'
9 `"Grade 9"'
11 `"Module 1 (grades 1 and 2)"'
22 `"Module 2 (grades 3 and 4)"'
33 `"Module 3 (grades 5 and 6)"'
;
label define turma
0 `"No letter"'
1 `"Turma A"'
2 `"Turma B"'
3 `"Turma C"'
4 `"Turma D"'
5 `"Turma E"'
6 `"Turma F"'
7 `"Turma G"'
8 `"Turma H"'
9 `"Turma I"'
10 `"Turma J"'
11 `"Turma K"'
12 `"Turma L"'
13 `"Turma M"'
14 `"Turma N"'
15 `"Turma O"'
16 `"Turma P"'
17 `"Turma Q"'
18 `"Turma R"'
19 `"Turma S"'
20 `"Turma T"'
;
label define shift
1 `"Morning"'
2 `"Afternoon"'
3 `"Night"'
;
label define freq1
0 `"Never"'
1 `"Once per week"'
2 `"Once per two weeks"'
3 `"Once per month"'
4 `"Once per two months"'
5 `"Once per trimester"'
6 `"Once per semester"'
7 `"Once per year"'
;
label define appointment
1 `"Directly appointed"'
2 `"Via elections"'
;
#delimit cr

foreach var in 	D03_03_01 D03_04_01	D03_07_01 D03_08_01	D03_03_02 D03_04_02	///
				D03_06_02 D03_08_02{
replace `var' = . if inlist(`var',999)
}


label variable D03_01_01 `"How many classes is the teacher teaching in pre-school"'
label values D03_01_01_01 grade
label variable D03_01_01_01 `"Grade of class"'

label values D03_01_02_01 turma
label variable D03_01_02_01 `"ID of class"'

label values D03_01_03_01 shift
label variable D03_01_03_01 `"Period/shift of class"'

label variable D03_02_01 `"How many students in the class"'
label variable D03_03_01 `"How many students were one day absent in the last two weeks"'
label variable D03_04_01 `"How many students were absent more than one day in the last two weeks"'

label variable D03_05_01__1 `"Teacher teaches Portuguese language to this class"'
label variable D03_05_01__2 `"Teacher teaches mathematics to this class"'
label variable D03_05_01__3 `"Teacher teaches geology to this class"'
label variable D03_05_01__4 `"Teacher teaches history to this class"'
label variable D03_05_01__5 `"Teacher teaches natural science to this class"'
label variable D03_05_01__6 `"Teacher teaches manual work to this class"'
label variable D03_05_01__7 `"Teacher teaches music to this class"'
label variable D03_05_01__8 `"Teacher teaches gymnastics to this class"'
label variable D03_05_01__9 `"Teacher teaches environment studies to this class"'

lab val D03_05_01__1 D03_05_01__2 D03_05_01__3 D03_05_01__4 D03_05_01__5 	///
		D03_05_01__6 D03_05_01__7 D03_05_01__8 D03_05_01__9 dummy

drop D03_05_01__10
gen D03_05_01__10 = 0 if D03_05_01__1!=.
gen D03_05_01__11 = 0 if D03_05_01__1!=.

label variable D03_05_01__10 `"Teacher teaches moral and civic education to this class"'
label variable D03_05_01__11 `"Teacher teaches chemistry to this class"'

lab val D03_05_01__10 D03_05_01__11 dummy

order D03_05_01__10 D03_05_01__11, after(D03_05_01__9)

replace D03_05_01__10 = 1 if D03_05_01_other=="Educação Moral e Civica"
replace D03_05_01__10 = 1 if D03_05_01_other=="Educação moral e civica"
replace D03_05_01__10 = 1 if D03_05_01_other=="Educação Moral e cívica"
replace D03_05_01__10 = 1 if D03_05_01_other=="Educação moral e Cívica"

replace D03_05_01__11 = 1 if D03_05_01_other=="Química"

foreach var in 	D03_05_01__1 D03_05_01__2 D03_05_01__3 D03_05_01__4			///
				D03_05_01__5 D03_05_01__6 D03_05_01__7 D03_05_01__8 		///
				D03_05_01__9 D03_05_01__10 D03_05_01__11 {
		replace `var' = 1 if D03_05_01_other=="Interligadas/ Interdisciplinarizadas"
}

drop D03_05_01_other

label variable D03_06_01 `"How many parents came to talk about students performance"'

label values D03_07_01 freq1
label variable D03_07_01 `"Frequency of meetings between teacher and parents"'

label variable D03_08_01 `"How many parents come in meetings"'

label values D03_09_01 dummy
label variable D03_09_01 `"Selected class has an organised group of parents"'

label values D03_10_01 appointment
label variable D03_10_01 `"Appointment of parents group representantive"'

drop D03_10_01_other

label values D03_01_01_02 grade
label variable D03_01_01_02 `"Grade of class"'

label values D03_01_02_02 turma
label variable D03_01_02_02 `"ID of class"'

label values D03_01_03_02 shift
label variable D03_01_03_02 `"Period of class"'

label variable D03_02_02 `"How many students in the class"'

label variable D03_03_02 `"How many students were one day absent in the last two weeks"'

label variable D03_04_02 `"How many students were absent more than one day in the last two weeks"'

label variable D03_05_02__1 `"Teacher teaches Portuguese language to this class"'
label variable D03_05_02__2 `"Teacher teaches mathematics to this class"'
label variable D03_05_02__3 `"Teacher teaches geology to this class"'
label variable D03_05_02__4 `"Teacher teaches history to this class"'
label variable D03_05_02__5 `"Teacher teaches natural science to this class"'
label variable D03_05_02__6 `"Teacher teaches manual work to this class"'
label variable D03_05_02__7 `"Teacher teaches music to this class"'
label variable D03_05_02__8 `"Teacher teaches gymnastics to this class"'
label variable D03_05_02__9 `"Teacher teaches environment studies to this class"'

lab val D03_05_02__1 D03_05_02__2 D03_05_02__3 D03_05_02__4 D03_05_02__5 	///
		D03_05_02__6 D03_05_02__7 D03_05_02__8 D03_05_02__9 dummy

drop D03_05_02__10 D03_05_02_other

label variable D03_06_02 `"How many parents came to talk about students performance"'

label values D03_07_02 freq1
label variable D03_07_02 `"Frequency of meetings between teacher and parents"'

label variable D03_08_02 `"How many parents come in meetings"'

label values D03_09_02 dummy
label variable D03_09_02 `"Selected class has an organised group of parents"'

label values D03_10_02 appointment
label variable D03_10_02 `"Nomination of parents group representantive"'

drop D03_10_02_other

label values D03_01_01_03 grade
label variable D03_01_01_03 `"Grade of class"'

label values D03_01_02_03 turma
label variable D03_01_02_03 `"ID of class"'

label values D03_01_03_03 shift
label variable D03_01_03_03 `"Period of class"'

label variable D03_02_03 `"How many students in the class"'

label variable D03_03_03 `"How many students were one day absent in the last two weeks"'

label variable D03_04_03 `"How many students were absent more than one day in the last two weeks"'

label variable D03_05_03__1 `"Teacher teaches Portuguese language to this class"'
label variable D03_05_03__2 `"Teacher teaches mathematics to this class"'
label variable D03_05_03__3 `"Teacher teaches geology to this class"'
label variable D03_05_03__4 `"Teacher teaches history to this class"'
label variable D03_05_03__5 `"Teacher teaches natural science to this class"'
label variable D03_05_03__6 `"Teacher teaches manual work to this class"'
label variable D03_05_03__7 `"Teacher teaches music to this class"'
label variable D03_05_03__8 `"Teacher teaches gymnastics to this class"'
label variable D03_05_03__9 `"Teacher teaches environment studies to this class"'

lab val D03_05_03__1 D03_05_03__2 D03_05_03__3 D03_05_03__4 D03_05_03__5 	///
		D03_05_03__6 D03_05_03__7 D03_05_03__8 D03_05_03__9 dummy

drop D03_05_03__10 D03_05_03_other

label variable D03_06_03 `"How many parents came to talk about students performance"'

label values D03_07_03 freq1
label variable D03_07_03 `"Frequency of meetings between teacher and parents"'

label variable D03_08_03 `"How many parents come in meetings"'

label values D03_09_03 dummy
label variable D03_09_03 `"Selected class has an organised group of parents"'

label values D03_10_03 appointment
label variable D03_10_03 `"Nomination of parents group representantive"'

drop D03_10_03_other

label variable D03_11__0 `"Teacher taught last year: pre-school"'
label variable D03_11__1 `"Teacher taught last year: grade 1"'
label variable D03_11__2 `"Teacher taught last year: grade 2"'
label variable D03_11__3 `"Teacher taught last year: grade 3"'
label variable D03_11__4 `"Teacher taught last year: grade 4"'
label variable D03_11__5 `"Teacher taught last year: grade 5"'
label variable D03_11__6 `"Teacher taught last year: grade 6"'
label variable D03_11__7 `"Teacher taught last year: grade 7"'
label variable D03_11__8 `"Teacher taught last year: grade 8"'
label variable D03_11__9 `"Teacher taught last year: grade 9"'
label variable D03_11__11 `"Teacher taught last year: module 1 (grades 1 and 2)"'
label variable D03_11__22 `"Teacher taught last year: module 2 (grades 3 and 4)"'
label variable D03_11__33 `"Teacher taught last year: module 3 (grades 5 and 6)"'

lab val D03_11__0 D03_11__1 D03_11__2 D03_11__3 D03_11__4 D03_11__5 		///
		D03_11__6 D03_11__7 D03_11__8 D03_11__9 D03_11__11 D03_11__22 		///
		D03_11__33 dummy

drop D03_11__999

label variable D03_11_00 `"Number of classes taught last year: pre-school"'
label variable D03_11_01 `"Number of classes taught last year: grade 1"'
label variable D03_11_02 `"Number of classes taught last year: grade 2"'
label variable D03_11_03 `"Number of classes taught last year: grade 3"'
label variable D03_11_04 `"Number of classes taught last year: grade 4"'
label variable D03_11_05 `"Number of classes taught last year: grade 5"'
label variable D03_11_06 `"Number of classes taught last year: grade 6"'
label variable D03_11_07 `"Number of classes taught last year: grade 7"'
label variable D03_11_08 `"Number of classes taught last year: grade 8"'
label variable D03_11_09 `"Number of classes taught last year: grade 9"'

label values D03_13 dummy
label variable D03_13 `"School diary / admin book"'

label values D03_14 dummy
label variable D03_14 `"Daily lesson plan"'

label variable D03_15__1 `"(Ordered) Teaching Method: Explain and read to students"'
label variable D03_15__2 `"(Ordered) Teaching Method: Writing on blackboard and students copy"'
label variable D03_15__3 `"(Ordered) Teaching Method: Students need to repeat several times"'
label variable D03_15__4 `"(Ordered) Teaching Method: Students reading out loud one by one"'
label variable D03_15__5 `"(Ordered) Teaching Method: Individual study, read in silence"'
label variable D03_15__6 `"(Ordered) Teaching Method: Interactively discussing with students"'
label variable D03_15__7 `"(Ordered) Teaching Method: Small group discussions/work"'

rename D03_15__8 D03_15__8_old

gen D03_15__8 = 0 if D03_15__1!=.
label variable D03_15__8 `"(Ordered) Teaching Method: Teacher mentions formal teaching method"'

replace D03_15__5 = D03_15__8_old if D03_15__5==0 & D03_15_other=="Trabalho independente"
replace D03_15__8 = D03_15__8_old if D03_15_other=="Esposicão"
replace D03_15__8 = D03_15__8_old if D03_15_other=="metodo socratico"

order D03_15__8, after(D03_15__7)

drop D03_15__0 D03_15__8_old D03_15__999 D03_15_other

foreach var in D03_16 D03_17 D03_18 D03_19 D03_20 D03_21 D03_22{
replace `var' = 0 if `var'==2
}

label values D03_16 dummy
label variable D03_16 `"Teaching Method: Explain and read to students"'

label values D03_17 dummy
label variable D03_17 `"Teaching Method: Writing on blackboard and students copy"'

label values D03_18 dummy
label variable D03_18 `"Teaching Method: Students need to repeat several times"'

label values D03_19 dummy
label variable D03_19 `"Teaching Method: Students reading out loud one by one"'

label values D03_20 dummy
label variable D03_20 `"Teaching Method: Individual study, read in silence"'

label values D03_21 dummy
label variable D03_21 `"Teaching Method: Interactively discussing with students"'

label values D03_22 dummy
label variable D03_22 `"Teaching Method: Small group discussions/work"'

drop D03_23 D03_23_other

label variable D03_24__1 `"(Ordered) Disciplinary Method: Talk to student"'
label variable D03_24__2 `"(Ordered) Disciplinary Method: Expel student"'
label variable D03_24__3 `"(Ordered) Disciplinary Method: Physical punishment"'
label variable D03_24__4 `"(Ordered) Disciplinary Method: Extra classes or homework"'
label variable D03_24__5 `"(Ordered) Disciplinary Method: Keep students in class after school"'
label variable D03_24__6 `"(Ordered) Disciplinary Method: Forbid sport or ludic activity"'
label variable D03_24__7 `"(Ordered) Disciplinary Method: Inform parents"'
label variable D03_24__8 `"(Ordered) Disciplinary Method: Manual labor"'
label variable D03_24__9 `"(Ordered) Disciplinary Method: Keep students inside the classroom during break"'

replace D03_24__4 = D03_24__10 if D03_24__4==0 & D03_24_other=="Aumentar as tarefas escolares."
replace D03_24__7 = D03_24__10 if D03_24__7==0 & D03_24_other=="Chamar ou falar com incarregado de educação"
replace D03_24__7 = D03_24__10 if D03_24__7==0 & D03_24_other=="Reunir o aluno com o pai ao mesmo tempo"


drop D03_24__0 D03_24__10 D03_24__999 D03_24_other

foreach var in D03_25 D03_26 D03_27 D03_28 D03_29 D03_30 D03_31 D03_32 D03_33{
replace `var' = 0 if `var'==2
}


label values D03_25 dummy
label variable D03_25 `"Disciplinary Method: Talk to student"'

label values D03_26 dummy
label variable D03_26 `"Disciplinary Method: Expel student"'

label values D03_27 dummy
label variable D03_27 `"Disciplinary Method: Physical punishment"'

label values D03_28 dummy
label variable D03_28 `"Disciplinary Method: Extra classes or homework"'

label values D03_29 dummy
label variable D03_29 `"Disciplinary Method: Keep students in class after school"'

label values D03_30 dummy
label variable D03_30 `"Disciplinary Method: Forbid sport or ludic activity"'

label values D03_31 dummy
label variable D03_31 `"Disciplinary Method: Inform parents"'

label values D03_32 dummy
label variable D03_32 `"Disciplinary Method: Manual labor"'

label values D03_33 dummy
label variable D03_33 `"Disciplinary Method: Keep students inside the classroom during break"'

drop D03_34 D03_34_other

********************************************************************************

********************************************************************************

* Section 4

// labelssss

#delimit ;
;
label define time
0 `"No time"'
1 `"Very little time"'
2 `"Little time"'
3 `"Not a lot not little time"'
4 `"A lot of time time"'
5 `"Almost all the time"'
;
#delimit cr

foreach var in D04_02_02 D04_02_04 D04_01_07{
replace `var' = . if inlist(`var',999,-999999999)
}

lab val D04_01_01 D04_01_02 D04_01_03 D04_01_04 D04_01_05 D04_01_06 		///
		D04_01_07 D04_01_08 D04_01_09 D04_01_10 dummy

lab val D04_02_01 D04_02_02 D04_02_03 D04_02_04 D04_02_05 D04_02_06 		///
		D04_02_07 D04_02_08 D04_02_09 D04_02_10 time

label variable D04_01_01 `"Director Responsibility: Teachers attendance"'
label variable D04_02_01 `"Director Responsibility (time spent): Teachers attendance"'
label variable D04_01_02 `"Director Responsibility: Students attendance"'
label variable D04_02_02 `"Director Responsibility (time spent): Students attendance"'
label variable D04_01_03 `"Director Responsibility: Classroom development"'
label variable D04_02_03 `"Director Responsibility (time spent): Classroom development"'
label variable D04_01_04 `"Director Responsibility: Teachers classroom plan"'
label variable D04_02_04 `"Director Responsibility (time spent): Teachers classroom plan"'
label variable D04_01_05 `"Director Responsibility: Teachers helping students"'
label variable D04_02_05 `"Director Responsibility (time spent): Teachers helping students"'
label variable D04_01_06 `"Director Responsibility: Teaching material availability"'
label variable D04_02_06 `"Director Responsibility (time spent): Teaching material availability"'
label variable D04_01_07 `"Director Responsibility: School accounting and budget"'
label variable D04_02_07 `"Director Responsibility (time spent): School accounting and budget"'
label variable D04_01_08 `"Director Responsibility: Direction and Operational meetings minutes"'
label variable D04_02_08 `"Director Responsibility (time spent): Direction and Operational meetings minutes"'
label variable D04_01_09 `"Director Responsibility: Yearly development plan"'
label variable D04_02_09 `"Director Responsibility (time spent): Yearly development plan"'
label variable D04_01_10 `"Director Responsibility: Report on students development"'
label variable D04_02_10 `"Director Responsibility (time spent): Report on students development"'

rename D04_03__6 D04_03__6_old

gen D04_03__6=0 if D04_03__1!=.
replace D04_03__6 = D04_03__6_old if D04_03__6==0 & D04_03_other=="Incentivar os encarregados a ajudarem no desenvolvimento e gestão da escola"
replace D04_03__6 = D04_03__6_old if D04_03__6==0 & D04_03_other=="Incentivar os pais a ajudar na reabilitação escolar"
replace D04_03__6 = D04_03__6_old if D04_03__6==0 & D04_03_other=="Incentivar os pais na Construção de novas salas anexas"
replace D04_03__6 = D04_03__6_old if D04_03__6==0 & D04_03_other=="Reunir com os pais a fim de ajudarem na manutenção da escola"
replace D04_03__6 = D04_03__6_old if D04_03__6==0 & D04_03_other=="Reuniu com os pais para ajudarem no desenvolvimento de escola"

order D04_03__6, after(D04_03__5)

label variable D04_03__1 "(Order) Actions to improve parents awareness: Encourage parents to help with the students' learning process"
label variable D04_03__2 `"(Order) Actions to improve parents awareness: Encourage parents to come to the school and meet with teachers"'
label variable D04_03__3 `"(Order) Actions to improve parents awareness: Encourage parents to create or join committees"'
label variable D04_03__4 `"(Order) Actions to improve parents awareness: Encourage parents to participate in board meetings"'
label variable D04_03__5 `"(Order) Actions to improve parents awareness: Encourage to ask for parent feedback"'
label variable D04_03__6 `"(Order) Actions to improve parents awareness: Encourage parents to help with construction and maintenance of school"'

drop D04_03__7 D04_03__6_old D04_03_other

rename D04_04__10 D04_04__10_old

gen D04_04__10=0 if D04_04__1!=.

replace D04_04__6 = D04_04__10_old if D04_04__6==0 & D04_04_other=="chamar os encarregado de educação para uma reonião"
replace D04_04__7 = D04_04__10_old if D04_04__7==0 & D04_04_other=="Obrigar o Aluno a Capinar"
replace D04_04__7 = D04_04__10_old if D04_04__7==0 & D04_04_other=="trabalhos manuais como limpar a escola"
replace D04_04__9 = D04_04__10_old if D04_04__9==0 & D04_04_other=="Conversar com o Aluno"
replace D04_04__9 = D04_04__10_old if D04_04__9==0 & D04_04_other=="reuniu com os alunos pra explicar o regulamento interno da escola"
replace D04_04__6 = D04_04__10_old if D04_04__6==0 & D04_04_other=="Comunicar ao soba os problemas da escola"
replace D04_04__10 = D04_04__10_old if D04_04__10==0 & D04_04_other=="Exigir que os professores fiquem atentos em tudo e em todos"
replace D04_04__10 = D04_04__10_old if D04_04__10==0 & D04_04_other=="Falar aos professores para passarem os regulamentos aos alunos"
replace D04_04__9 = D04_04__10_old if D04_04__9==0 & D04_04_other=="Obrigar a contar historia aos colegas"
replace D04_04__3 = D04_04__10_old if D04_04__3==0 & D04_04_other=="Projecto educativo"
replace D04_04__10 = D04_04__10_old if D04_04__10==0 & D04_04_other=="Criou-se uma comissão de disciplina"

order D04_04__10, after(D04_04__9)

label variable D04_04__1 `"(Order) Actions to discipline students: Expel student"'
label variable D04_04__2 `"(Order) Actions to discipline students: Physical punishment"'
label variable D04_04__3 `"(Order) Actions to discipline students: Extra classes or homework"'
label variable D04_04__4 `"(Order) Actions to discipline students: Keep students in class after school"'
label variable D04_04__5 `"(Order) Actions to discipline students: Forbid sport or ludic activity"'
label variable D04_04__6 `"(Order) Actions to discipline students: Inform parents"'
label variable D04_04__7 `"(Order) Actions to discipline students: Manual labor"'
label variable D04_04__8 `"(Order) Actions to discipline students: Keep students inside the classroom during break"'
label variable D04_04__9 `"(Order) Actions to discipline students: Talk to student"'
label variable D04_04__10 `"(Order) Actions to discipline students: Leave it to teachers"'

drop D04_04__10_old D04_04__11 D04_04_other

rename D04_05__10 D04_05__10_old
drop D04_05__11
gen D04_05__10=0 if D04_05__1!=.
gen D04_05__11=0 if D04_05__1!=.

replace D04_05__7 = D04_05__10_old if D04_05_other=="conversar com os pais" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Conversar com os pais e encarregado de educação." & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="conversar com os pais e encarregado escolar.." & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Falar com os pais" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Ir ao encontro dos encarregados" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Mobilização com os Pais" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Pedir aos encarregados reforçar a alimentação" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Reportar-se aos pais e encarregado de educação." & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="reunião dos encarregados com os professores" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Reunir com os pais e Encarregado de Educação" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Sanções como faltas na caderneta" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Visita do professor em casa do aluno" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Visitas De constatações das condições de vida dos alunos" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Visitas dos funcionários da escola ao aluno" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Visitas dos professores aos alunos" & D04_05__7 ==0
replace D04_05__7 = D04_05__10_old if D04_05_other=="Visitas dos professores em casa dos alunos" & D04_05__7 ==0
replace D04_05__9 = D04_05__10_old if D04_05_other=="Falar com ele sobre a importância dos estudos" & D04_05__9 ==0
replace D04_05__10 = D04_05__10_old if D04_05_other=="conversar com os professores" & D04_05__10 ==0
replace D04_05__10 = D04_05__10_old if D04_05_other=="Obrigar aos professores falar muito com os alunos" & D04_05__10 ==0
replace D04_05__10 = D04_05__10_old if D04_05_other=="Presença Activa dos Professores" & D04_05__10 ==0
replace D04_05__10 = D04_05__10_old if D04_05_other=="sensibilização dos professores" & D04_05__10 ==0
replace D04_05__11 = D04_05__10_old if D04_05_other=="Actividade extra escolar" & D04_05__11 ==0
replace D04_05__11 = D04_05__10_old if D04_05_other=="organizar actividades recreativas" & D04_05__11 ==0
replace D04_05__11 = D04_05__10_old if D04_05_other=="Realização de actividades extra curriculares" & D04_05__11 ==0
replace D04_05__11 = D04_05__10_old if D04_05_other=="Dar insentivos aos alunos" & D04_05__11 ==0
replace D04_05__11 = D04_05__10_old if D04_05_other=="Estimular os alunos." & D04_05__11 ==0
replace D04_05__11 = D04_05__10_old if D04_05_other=="Oferecia aos alunos chiclete" & D04_05__11 ==0
replace D04_05__11 = D04_05__10_old if D04_05_other=="Premios aos alunos assíduos" & D04_05__11 ==0

label variable D04_05__1 `"(Order) Actions to fight absence of students: Expel student"'
label variable D04_05__2 `"(Order) Actions to fight absence of students: Physical punishment"'
label variable D04_05__3 `"(Order) Actions to fight absence of students: Extra classes or homework"'
label variable D04_05__4 `"(Order) Actions to fight absence of students: Keep students in class after school"'
label variable D04_05__5 `"(Order) Actions to fight absence of students: Forbid sport or ludic activity"'
label variable D04_05__6 `"(Order) Actions to fight absence of students: Inform parents"'
label variable D04_05__7 `"(Order) Actions to fight absence of students: Manual labor"'
label variable D04_05__8 `"(Order) Actions to fight absence of students: Keep students inside the classroom during break"'
label variable D04_05__9 `"(Order) Actions to fight absence of students: Talk to student"'
label variable D04_05__10 `"(Order) Actions to fight absence of students: Leave it to teachers"'
label variable D04_05__11 `"(Order) Actions to fight absence of students: Create incentives such as prizes and extracuricular activities"'

drop D04_05__10_old D04_05_other

order D04_05__10 D04_05__11, after(D04_05__9)

rename D04_06__9 D04_06__9_old

gen D04_06__9 = 0 if D04_06__1!=.

replace D04_06__3 = D04_06__9_old if D04_06_other=="avaliações negativa!" & D04_06__3 ==0
replace D04_06__3 = D04_06__9_old if D04_06_other=="Dar a conhecer os prejuizos que as audiências causam" & D04_06__3 ==1
replace D04_06__3 = D04_06__9_old if D04_06_other=="Reuniões Com todos eles." & D04_06__3 ==2
replace D04_06__3 = D04_06__9_old if D04_06_other=="Reuniões e apelo" & D04_06__3 ==3
replace D04_06__5 = D04_06__9_old if D04_06_other=="Comunicar a direção Municipal para ver a situação do professor que assim continua a faltar depois da chamada de atenção" & D04_06__5 ==4
replace D04_06__5 = D04_06__9_old if D04_06_other=="Informação a cordenação comunal" & D04_06__5 ==5
replace D04_06__6 = D04_06__9_old if D04_06_other=="aplicação de falta" & D04_06__6 ==6
replace D04_06__6 = D04_06__9_old if D04_06_other=="Aplicação de faltas" & D04_06__6 ==7
replace D04_06__6 = D04_06__9_old if D04_06_other=="Criar um processo disciplinar" & D04_06__6 ==8
replace D04_06__6 = D04_06__9_old if D04_06_other=="Envio de mapa de  efectivida." & D04_06__6 ==9
replace D04_06__6 = D04_06__9_old if D04_06_other=="Faltas" & D04_06__6 ==10
replace D04_06__6 = D04_06__9_old if D04_06_other=="Marcar falta ao mesmo" & D04_06__6 ==11
replace D04_06__6 = D04_06__9_old if D04_06_other=="Reunir o professor junto a direção da escola" & D04_06__6 ==12
replace D04_06__9 = D04_06__9_old if D04_06_other=="Aluguer de uma casa por parte dos encarregado" & D04_06__9 ==13
replace D04_06__9 = D04_06__9_old if D04_06_other=="Passar mais tempo na escola sem regressar para suas famílias" & D04_06__9 ==14

label variable D04_06__1 `"(Order) Absence of teachers is not a problem at this school"'
label variable D04_06__2 `"(Order) Actions to fight absence of teachers: No action taken"'
label variable D04_06__3 `"(Order) Actions to fight absence of teachers: Talk to teacher"'
label variable D04_06__4 `"(Order) Actions to fight absence of teachers: Report to provincial board"'
label variable D04_06__5 `"(Order) Actions to fight absence of teachers: Report to municipal board"'
label variable D04_06__6 `"(Order) Actions to fight absence of teachers: Report to school board"'
label variable D04_06__7 `"(Order) Actions to fight absence of teachers: Suspend/transfer"'
label variable D04_06__8 `"(Order) Actions to fight absence of teachers: Salary cut"'
label variable D04_06__9 `"(Order) Actions to fight absence of teachers: Provide accomodation close to school"'

drop D04_06__10 D04_06_other D04_06__9_old

order D04_06__9, after(D04_06__8)


********************************************************************************

********************************************************************************

* Section 5 (teacher section 4)


// labelssss

#delimit ;
;
label define responsible
1 `"Director"'
2 `"Deputy director"'
3 `"School board"'
4 `"Another senior teacher"'
5 `"Another teacher"'
6 `"Representative of provincial board"'
7 `"Representative of municipal/comunal board"'
8 `"Representative of ministry of education"'
9 `"Other (not specified)"'
;
#delimit cr

rename D05_10_other D05_10_12

foreach var in D05_01 D05_02_01 D05_03_01 D05_02_02 D05_03_02 D05_02_03 	///
	D05_03_03 D05_02_04 D05_03_04 D05_02_05 D05_03_05 D05_02_06 D05_03_06 	///
	D05_02_07 D05_03_07 D05_02_08 D05_03_08 D05_02_09 D05_03_09 D05_02_10 	///
	D05_03_10_other D05_04 D05_05_01 D05_05_02__1  							///
	D05_05_02__2 D05_05_02__3 D05_05_02__4 D05_05_02__5 D05_05_02__6  		///
	D05_05_02__7 D05_05_02__8 D05_05_02__9 D05_05_02__10 D05_05_02__11  	///
	D05_05_02__12 D05_06_01 D05_07_01 D05_06_02 D05_07_02  					///
	D05_06_03 D05_07_03 D05_06_04 D05_07_04 D05_06_05 D05_07_05 D05_06_06 	///
	D05_07_06 D05_06_07 D05_07_07 D05_06_08 D05_07_08 D05_06_09 D05_07_09 	///
	D05_06_10 D05_07_10 D05_06_11 D05_07_11 D05_06_12 D05_07_12 D05_08_01 	///
	D05_08_02__1 D05_08_02__2 D05_08_02__3 D05_08_02__4 D05_08_02__5  		///
	D05_08_02__6 D05_08_02__7 D05_08_02__8 D05_08_02__9 D05_08_02__10  		///
	D05_08_02__11 D05_08_02__12  								///
	D05_09_01 D05_10_01 D05_09_02 D05_10_02 D05_09_03 D05_10_03 D05_09_04 	///
	D05_10_04 D05_09_05 D05_10_05 D05_09_06 D05_10_06 D05_09_07 D05_10_07 	///
	D05_09_08 D05_10_08 D05_09_09 D05_10_09 D05_09_10 D05_10_10 D05_09_11 	///
	D05_10_11 D05_09_12 D05_10_12 {
replace `var' = . if inlist(`var',999,-999999999)
}

label values D05_01 dummy
label variable D05_01 `"Director is formally evaluated"'

lab val D05_02_01 D05_02_02 D05_02_03 D05_02_04 D05_02_05 D05_02_06 		///
		D05_02_07 D05_02_08 D05_02_09 D05_02_10 dummy

rename D05_03_10_other D05_03_10

lab val D05_03_01 D05_03_02 D05_03_03 D05_03_04 D05_03_05 D05_03_06 		///
		D05_03_07 D05_03_08 D05_03_09 D05_03_10 responsible

label variable D05_02_01 `"Performance Evaluation Method: Observation in class"'
label variable D05_03_01 `"Responsible for Evaluation Method: Observation in class"'
label variable D05_02_02 `"Performance Evaluation Method: Students classification"'
label variable D05_03_02 `"Responsible for Evaluation Method: Students classification"'
label variable D05_02_03 `"Performance Evaluation Method: Work done by students"'
label variable D05_03_03 `"Responsible for Evaluation Method: Work done by students"'
label variable D05_02_04 `"Performance Evaluation Method: Students attendance"'
label variable D05_03_04 `"Responsible for Evaluation Method: Students attendance"'
label variable D05_02_05 `"Performance Evaluation Method: Employees interview"'
label variable D05_03_05 `"Responsible for Evaluation Method: Employees interview"'
label variable D05_02_06 `"Performance Evaluation Method: Monitoring daily tasks"'
label variable D05_03_06 `"Responsible for Evaluation Method: Monitoring daily tasks"'
label variable D05_02_07 `"Performance Evaluation Method: Director and teachers attendance"'
label variable D05_03_07 `"Responsible for Evaluation Method: Director and teachers attendance"'
label variable D05_02_08 `"Performance Evaluation Method: Monitoring of other reports"'
label variable D05_03_08 `"Responsible for Evaluation Method: Monitoring of other reports"'
label variable D05_02_09 `"Performance Evaluation Method: Parents satisfaction with students performance"'
label variable D05_03_09 `"Responsible for Evaluation Method: Parents satisfaction with students performance"'

replace D05_02_06 = 1 if D05_02_10_other=="Manter a higiene escolar"
replace D05_03_06 = D05_03_10 if D05_02_10_other=="Manter a higiene escolar"
replace D05_02_08 = 1 if D05_02_10_other=="Pelo numero de Matricula"
replace D05_03_08 = D05_03_10 if D05_02_10_other=="Pelo numero de Matricula"

drop D05_02_10 D05_02_10_other D05_03_10

label variable D05_04 `"Late in last two weeks"'
label variable D05_05_01 `"Days absence in last two weeks"'

replace D05_04 = 10 if D05_04>10 & D05_04!=.
replace D05_05_01 = 10 if D05_05_01>10 & D05_05_01!=.

rename D05_05_02__12 D05_05_02__12_old
rename D05_06_12 D05_06_12_old
rename D05_07_12 D05_07_12_old

gen D05_05_02__12 = 0 if D05_05_02__1!=.
gen D05_05_02__13 = 0 if D05_05_02__1!=.
gen D05_06_12 = .
gen D05_06_13 = .
gen D05_07_12 = .
gen D05_07_13 = .

order D05_05_02__12 D05_05_02__13, after(D05_05_02__11)
order D05_06_11 D05_07_11 D05_06_12 D05_07_12 D05_06_13 D05_07_13, after(D05_07_10)

replace D05_05_02__1= 1 if D05_05_02_other=="repouso médico"
replace D05_05_02__3= 1 if D05_05_02_other=="Falecimento da mãe de um colega"
replace D05_05_02__7= 1 if D05_05_02_other=="Seminário na direção municipal da educação"
replace D05_05_02__8= 1 if D05_05_02_other=="Levar uma informação a repartição"
replace D05_05_02__8= 1 if D05_05_02_other=="Reunião com o administrador Municipal"
replace D05_05_02__12= 1 if D05_05_02_other=="Estava de férias"
replace D05_05_02__12= 1 if D05_05_02_other=="Férias"

replace D05_06_01= D05_06_12_old if D05_05_02_other=="repouso médico"
replace D05_06_03= D05_06_12_old if D05_05_02_other=="Falecimento da mãe de um colega"
replace D05_06_07= D05_06_12_old if D05_05_02_other=="Seminário na direção municipal da educação"
replace D05_06_08= D05_06_12_old if D05_05_02_other=="Levar uma informação a repartição"
replace D05_06_08= D05_06_12_old if D05_05_02_other=="Reunião com o administrador Municipal"
replace D05_06_12= D05_06_12_old if D05_05_02_other=="Estava de férias"
replace D05_06_12= D05_06_12_old if D05_05_02_other=="Férias"

replace D05_07_01= D05_07_12_old if D05_05_02_other=="repouso médico"
replace D05_07_03= D05_07_12_old if D05_05_02_other=="Falecimento da mãe de um colega"
replace D05_07_07= D05_07_12_old if D05_05_02_other=="Seminário na direção municipal da educação"
replace D05_07_08= D05_07_12_old if D05_05_02_other=="Levar uma informação a repartição"
replace D05_07_08= D05_07_12_old if D05_05_02_other=="Reunião com o administrador Municipal"
replace D05_07_12= D05_07_12_old if D05_05_02_other=="Estava de férias"
replace D05_07_12= D05_07_12_old if D05_05_02_other=="Férias"

label variable D05_05_02__1 `"(last2weeks) Teacher was absent due to own sickness"'
label variable D05_05_02__2 `"(last2weeks) Teacher was absent due to family member sickness"'
label variable D05_05_02__3 `"(last2weeks) Teacher was absent due to death family/friend"'
label variable D05_05_02__4 `"(last2weeks) Teacher was absent due to other domestic/family emergency (including weddings)"'
label variable D05_05_02__5 `"(last2weeks) Teacher was absent due to salary day (travel to municipality center)"'
label variable D05_05_02__6 `"(last2weeks) Teacher was absent due to purchase of school resources"'
label variable D05_05_02__7 `"(last2weeks) Teacher was absent due to workshop"'
label variable D05_05_02__8 `"(last2weeks) Teacher was absent due to other reason related to teaching"'
label variable D05_05_02__9 `"(last2weeks) Teacher was absent due to second professional activity"'
label variable D05_05_02__10 `"(last2weeks) Teacher was absent due to rain"'
label variable D05_05_02__11 `"(last2weeks) Teacher was absent due to lack of transportation"'
label variable D05_05_02__12 `"(last2weeks) Teacher was absent due to personal reasons"'
label variable D05_05_02__13 `"(last2weeks) Teacher was absent due to child birth related topics"'


lab val  D05_05_02__1 D05_05_02__2 D05_05_02__3 D05_05_02__4 D05_05_02__5 	///
			D05_05_02__6 D05_05_02__7 D05_05_02__8 D05_05_02__9 			///
			D05_05_02__10 D05_05_02__11 D05_05_02__12 D05_05_02__13 dummy

label variable D05_06_01 `"(last2weeks) Days absent due to own sickness"'
label variable D05_06_02 `"(last2weeks) Days absent due to family member sickness"'
label variable D05_06_03 `"(last2weeks) Days absent due to death family/friend"'
label variable D05_06_04 `"(last2weeks) Days absent due to other domestic/family emergency (including weddings)"'
label variable D05_06_05 `"(last2weeks) Days absent due to salary day (travel to municipality center)"'
label variable D05_06_06 `"(last2weeks) Days absent due to purchase of school resources"'
label variable D05_06_07 `"(last2weeks) Days absent due to workshop"'
label variable D05_06_08 `"(last2weeks) Days absent due to other reason related to teaching"'
label variable D05_06_09 `"(last2weeks) Days absent due to second professional activity"'
label variable D05_06_10 `"(last2weeks) Days absent due to rain"'
label variable D05_06_11 `"(last2weeks) Days absent due to lack of transportation"'
label variable D05_06_12 `"(last2weeks) Days absent due to personal reasons"'
label variable D05_06_13 `"(last2weeks) Days absent due to child birth related topics"'

foreach var in D05_06_01 D05_06_02 D05_06_03 D05_06_04 D05_06_05 D05_06_06 ///
	D05_06_07 D05_06_08 D05_06_09 D05_06_10 D05_06_11 D05_06_12 D05_06_13{
		replace `var' = 10 if `var'>10 & `var'!=.
}

label variable D05_07_01 `"(last2weeks) Notification given of absence due to own sickness"'
label variable D05_07_02 `"(last2weeks) Notification given of absence due family member sickness"'
label variable D05_07_03 `"(last2weeks) Notification given of absence due to death family/friend"'
label variable D05_07_04 `"(last2weeks) Notification given of absence due to other domestic/family emergency (including weddings)"'
label variable D05_07_05 `"(last2weeks) Notification given of absence due to salary day (travel to municipality center)"'
label variable D05_07_06 `"(last2weeks) Notification given of absence due to purchase of school resources"'
label variable D05_07_07 `"(last2weeks) Notification given of absence due to workshop"'
label variable D05_07_08 `"(last2weeks) Notification given of absence due to other reason related to teaching"'
label variable D05_07_09 `"(last2weeks) Notification given of absence due to second professional activity"'
label variable D05_07_10 `"(last2weeks) Notification given of absence due to rain"'
label variable D05_07_11 `"(last2weeks) Notification given of absence due to lack of transportation"'
label variable D05_07_12 `"(last2weeks) Notification given of absence due to personal reasons"'
label variable D05_07_13 `"(last2weeks) Notification given of absence due to child birth related topics"'

lab val D05_07_01 D05_07_02 D05_07_03 D05_07_04 D05_07_05 D05_07_06 		///
	D05_07_07 D05_07_08 D05_07_09 D05_07_10 D05_07_11 D05_07_12 D05_07_13 dummy

drop D05_05_02__12_old D05_05_02_other D05_06_12_old D05_07_12_old

replace D05_08_01 = . if inlist(D05_08_01,99,9999)
label variable D05_08_01 `"Days absence in November 2017"'
replace D05_08_01 = 30 if D05_08_01>30 & D05_08_01!=.

rename D05_08_02__12 D05_08_02__12_old
rename D05_09_12 D05_09_12_old
rename D05_10_12 D05_10_12_old

gen D05_08_02__12 = 0 if D05_08_02__1!=.
gen D05_08_02__13 = 0 if D05_08_02__1!=.
gen D05_09_12 = .
gen D05_09_13 = .
gen D05_10_12 = .
gen D05_10_13 = .

order D05_08_02__12 D05_08_02__13, after(D05_08_02__11)
order D05_09_11 D05_10_11 D05_09_12 D05_10_12 D05_09_13 D05_10_13, after(D05_10_10)

replace D05_08_02__3 = 1  if D05_08_02_other=="Funeral de um vizinho"
replace D05_08_02__3 = 1  if D05_08_02_other=="Óbito  nas proximidades da escola"
replace D05_08_02__8 = 1  if D05_08_02_other=="Esteve a fazer provas de exames"

replace D05_09_03 = D05_09_12_old  if D05_08_02_other=="Funeral de um vizinho"
replace D05_09_03 = D05_09_12_old  if D05_08_02_other=="Óbito  nas proximidades da escola"
replace D05_09_08 = D05_09_12_old  if D05_08_02_other=="Esteve a fazer provas de exames"

replace D05_10_03 = D05_10_12_old  if D05_08_02_other=="Funeral de um vizinho"
replace D05_10_03 = D05_10_12_old  if D05_08_02_other=="Óbito  nas proximidades da escola"
replace D05_10_08 = D05_10_12_old  if D05_08_02_other=="Esteve a fazer provas de exames"

label variable D05_08_02__1 `"(nov17) Teacher was absent due to own sickness"'
label variable D05_08_02__2 `"(nov17) Teacher was absent due to family member sickness"'
label variable D05_08_02__3 `"(nov17) Teacher was absent due to death family/friend"'
label variable D05_08_02__4 `"(nov17) Teacher was absent due to other domestic/family emergency (including weddings)"'
label variable D05_08_02__5 `"(nov17) Teacher was absent due to salary day (travel to municipality center)"'
label variable D05_08_02__6 `"(nov17) Teacher was absent due to purchase of school resources"'
label variable D05_08_02__7 `"(nov17) Teacher was absent due to workshop"'
label variable D05_08_02__8 `"(nov17) Teacher was absent due to other reason related to teaching"'
label variable D05_08_02__9 `"(nov17) Teacher was absent due to second professional activity"'
label variable D05_08_02__10 `"(nov17) Teacher was absent due to rain"'
label variable D05_08_02__11 `"(nov17) Teacher was absent due to lack of transportation"'
label variable D05_08_02__12 `"(nov17) Teacher was absent due to personal reasons"'
label variable D05_08_02__13 `"(nov17) Teacher was absent due to child birth related topics"'

lab val  D05_08_02__1 D05_08_02__2 D05_08_02__3 D05_08_02__4 D05_08_02__5 	///
			D05_08_02__6 D05_08_02__7 D05_08_02__8 D05_08_02__9 			///
			D05_08_02__10 D05_08_02__11 D05_08_02__12 D05_08_02__13 dummy

label variable D05_09_01 `"(nov17) Days absent due to own sickness"'
label variable D05_09_02 `"(nov17) Days absent due to family member sickness"'
label variable D05_09_03 `"(nov17) Days absent due to death family/friend"'
label variable D05_09_04 `"(nov17) Days absent due to other domestic/family emergency (including weddings)"'
label variable D05_09_05 `"(nov17) Days absent due to salary day (travel to municipality center)"'
label variable D05_09_06 `"(nov17) Days absent due to purchase of school resources"'
label variable D05_09_07 `"(nov17) Days absent due to workshop"'
label variable D05_09_08 `"(nov17) Days absent due to other reason related to teaching"'
label variable D05_09_09 `"(nov17) Days absent due to second professional activity"'
label variable D05_09_10 `"(nov17) Days absent due to rain"'
label variable D05_09_11 `"(nov17) Days absent due to lack of transportation"'
label variable D05_09_12 `"(nov17) Days absent due to personal reasons"'
label variable D05_09_13 `"(nov17) Days absent due to child birth related topics"'

foreach var in D05_09_01 D05_09_02 D05_09_03 D05_09_04 D05_09_05 D05_09_06 ///
	D05_09_07 D05_09_08 D05_09_09 D05_09_10 D05_09_11 D05_09_12 D05_09_13{
		replace `var' = 30 if `var'>30 & `var'!=.
}

label variable D05_10_01 `"(nov17) Notification given of absence due to own sickness"'
label variable D05_10_02 `"(nov17) Notification given of absence due family member sickness"'
label variable D05_10_03 `"(nov17) Notification given of absence due to death family/friend"'
label variable D05_10_04 `"(nov17) Notification given of absence due to other domestic/family emergency (including weddings)"'
label variable D05_10_05 `"(nov17) Notification given of absence due to salary day (travel to municipality center)"'
label variable D05_10_06 `"(nov17) Notification given of absence due to purchase of school resources"'
label variable D05_10_07 `"(nov17) Notification given of absence due to workshop"'
label variable D05_10_08 `"(nov17) Notification given of absence due to other reason related to teaching"'
label variable D05_10_09 `"(nov17) Notification given of absence due to second professional activity"'
label variable D05_10_10 `"(nov17) Notification given of absence due to rain"'
label variable D05_10_11 `"(nov17) Notification given of absence due to lack of transportation"'
label variable D05_10_12 `"(nov17) Notification given of absence due to personal reasons"'
label variable D05_10_13 `"(nov17) Notification given of absence due to child birth related topics"'

lab val D05_10_01 D05_10_02 D05_10_03 D05_10_04 D05_10_05 D05_10_06 		///
	D05_10_07 D05_10_08 D05_10_09 D05_10_10 D05_10_11 D05_10_12 D05_10_13 dummy

drop D05_08_02__12_old D05_08_02_other D05_09_12_old D05_10_12_old


drop 	D05_05_02__13 D05_06_13 D05_07_13 D05_08_02__12 D05_08_02__13 		///
		D05_09_12 D05_10_12 D05_09_13 D05_10_13

********************************************************************************

********************************************************************************

* Section 6

// labelssss

#delimit ;
;
label define good
1 `"Very good"'
2 `"Good"'
3 `"Reasonable"'
4 `"Weak"'
5 `"Very weak"'
;
#delimit cr

replace D06_01 = . if D06_01 ==999
replace D06_02 = . if D06_02== 999
replace D06_03 = . if D06_03== 999

label variable D06_01 `"Number of visits by Provincial Education Directorate representative"'
label variable D06_02 `"Number of times director was called to Provincial Education Directorate"'
label values D06_03 good
label variable D06_03 `"Relationship with Provincial Education Directorate"'
label values D06_04 good
label variable D06_04 `"Relationship with parents committee"'

label variable D06_05__0 `"Director does nothing when parents complain about teacher performance"'
label variable D06_05__1 `"Director cannot do anything when parents complain about teacher performance"'
label variable D06_05__2 `"Director talks to teacher when parents complain about teacher performance"'
label variable D06_05__3 `"Director gives teacher sanctions when parents complain about teacher performance"'
label variable D06_05__4 `"Director observes/helps better the teacher when parents complain about teacher performance"'
label variable D06_05__5 `"Director would only act if multiple parents complain about teacher performance"'
label variable D06_05__6 `"Director would do something else (not specified)"'

lab val D06_05__0 D06_05__1 D06_05__2 D06_05__3 D06_05__4 D06_05__5 		///
		D06_05__6 dummy

drop D06_05__0 D06_05__999 D06_05_other

********************************************************************************

********************************************************************************

* Section 7 (P4 / T5 / D7)

// labelssss

#delimit ;
;
label define problem
0 `"Not a problem"'
1 `"Small problem"'
2 `"Average problem"'
3 `"Big problem"'
;
#delimit cr

foreach var in  D07_01__0 D07_01__1 D07_01__2 D07_01__3 D07_01__4 			///
	D07_01__5 D07_01__6 D07_01__7 D07_01__8 D07_01__9 D07_01__10 			///
	D07_01__11 D07_01__12 D07_01__13 D07_01__14 D07_01__15 D07_01__16 		///
	D07_01__17 D07_01__18 D07_01__19 D07_01__20						 		///
	D07_01__999 D07_02__0 D07_02__1 D07_02__2 D07_02__3 D07_02__4 			///
	D07_02__5 D07_02__6 D07_02__7 D07_02__8 D07_02__9 D07_02__10 			///
	D07_02__11 D07_02__12 D07_02__13 D07_02__14 D07_02__15 D07_02__16 		///
	D07_02__17 D07_02__18 D07_02__19 D07_02__20 D07_02__21 D07_02__22 		///
	D07_02__23 D07_02__24 D07_02__25 D07_02__26 D07_02__27 D07_02__28 		///
	D07_02__29 D07_02__30 D07_02__31 D07_02__999 D07_03 D07_04 D07_05 		///
	D07_06 D07_07 D07_08 D07_09 D07_10 D07_11 D07_12 D07_13 D07_14 			///
	D07_15 D07_16 D07_17 D07_18 D07_19 D07_20 D07_21 D07_22 D07_23 			///
	D07_24 D07_25 D07_26 D07_27 D07_28 D07_29 D07_30 D07_31 D07_32 D07_33{
		replace `var' = . if inlist(`var',999,-999999999)
}

rename D07_01__20 D07_01__20_old

gen D07_01__20 = 0 if D07_01__1!=.
gen D07_01__21 = 0 if D07_01__1!=.
gen D07_01__22 = 0 if D07_01__1!=.
gen D07_01__23 = 0 if D07_01__1!=.

order D07_01__20 D07_01__21 D07_01__22 D07_01__23, after(D07_01__19)

replace D07_01__1 = D07_01__20_old if D07_01_other=="construção de conhecimento" & D07_01__1 == 0
replace D07_01__6 = D07_01__20_old if D07_01_other=="Alojamento e alimentação aos professores estagiário" & D07_01__6 == 0
replace D07_01__6 = D07_01__20_old if D07_01_other=="Construção da residência dos Professores" & D07_01__6 == 0
replace D07_01__6 = D07_01__20_old if D07_01_other=="Construção da sala dos professores" & D07_01__6 == 0
replace D07_01__6 = D07_01__20_old if D07_01_other=="criação de uma orta escolar" & D07_01__6 == 0
replace D07_01__6 = D07_01__20_old if D07_01_other=="Horta escolar" & D07_01__6 == 0
replace D07_01__8 = D07_01__20_old if D07_01_other=="Foi-nos ofertado uma caixa de giz" & D07_01__8 == 0
replace D07_01__8 = D07_01__20_old if D07_01_other=="Recibemento de materias didático" & D07_01__8 == 0
replace D07_01__8 = D07_01__20_old if D07_01_other=="Melhoria das condições de trabalho com materiais informaticos" & D07_01__8 == 0
replace D07_01__9 = D07_01__20_old if D07_01_other=="Criado do projecto educativo" & D07_01__9 == 0
replace D07_01__9 = D07_01__20_old if D07_01_other=="Projecto educativoss" & D07_01__9 == 0
replace D07_01__9 = D07_01__20_old if D07_01_other=="Realização das jornadas Científico Pedagogica" & D07_01__9 == 0
replace D07_01__15 = D07_01__20_old if D07_01_other=="Assiduidade e pontualidade dos professores" & D07_01__15 == 0
replace D07_01__19 = D07_01__20_old if D07_01_other=="Comparticipação dos encarregados para a gestão escolar" & D07_01__19 == 0
replace D07_01__19 = D07_01__20_old if D07_01_other=="Melhorou A comissão de pais" & D07_01__19 == 0
replace D07_01__19 = D07_01__20_old if D07_01_other=="Relações mútua com pais e encarregado de educação." & D07_01__19 == 0
replace D07_01__19 = D07_01__20_old if D07_01_other=="Uma boa relação com os encarregado de educação" & D07_01__19 == 0
replace D07_01__20 = D07_01__20_old if D07_01_other=="Melhorou a higiene escolar" & D07_01__20 == 0
replace D07_01__20 = D07_01__20_old if D07_01_other=="Constituiu-se 2 Segurança, Uma auxiliar de limpeza" & D07_01__20 == 0
replace D07_01__20 = D07_01__20_old if D07_01_other=="Aumento de empregada." & D07_01__20 == 0
replace D07_01__21 = D07_01__20_old if D07_01_other=="Diminuiu a delinquência" & D07_01__21 == 0
replace D07_01__21 = D07_01__20_old if D07_01_other=="Melhorou a segurança" & D07_01__21 == 0
replace D07_01__23 = D07_01__20_old if D07_01_other=="Electricidade, e Água" & D07_01__23 == 0
replace D07_01__23 = D07_01__20_old if D07_01_other=="Melhorou o fornecimento de água e electricidade" & D07_01__23 == 0
replace D07_01__23 = D07_01__20_old if D07_01_other=="Abastecimento de Água e Reprodução das provas" & D07_01__23 == 0
replace D07_01__23 = D07_01__20_old if D07_01_other=="Melhoramento na electricidade das salas de aulas,  e o tecto das falso das mesmas" & D07_01__23 == 0

label variable D07_01__1 `"(ordered) Achievements: Improved classrooms"'
label variable D07_01__2 `"(ordered) Achievements: Build new classrooms"'
label variable D07_01__3 `"(ordered) Achievements: Improved bathrooms"'
label variable D07_01__4 `"(ordered) Achievements: Build new bathrooms"'
label variable D07_01__5 `"(ordered) Achievements: Improved other facilities (e.g.: field, fence, library)"'
label variable D07_01__6 `"(ordered) Achievements: Build new other facilities (e.g.: field, fence, library)"'
label variable D07_01__7 `"(ordered) Achievements: Improved school material and furniture"'
label variable D07_01__8 `"(ordered) Achievements: Bought new school material and furniture"'
label variable D07_01__9 `"(ordered) Achievements: Encouraged/organized extracurricular activities"'
label variable D07_01__10 `"(ordered) Achievements: Student test results improved"'
label variable D07_01__11 `"(ordered) Achievements: Overal student performance improved"'
label variable D07_01__12 `"(ordered) Achievements: Reducerd student absentism"'
label variable D07_01__13 `"(ordered) Achievements: Reducerd student drop-out rate"'
label variable D07_01__14 `"(ordered) Achievements: Teacher performance improved"'
label variable D07_01__15 `"(ordered) Achievements: Reduced teacher absentism"'
label variable D07_01__16 `"(ordered) Achievements: Teacher conditions improved (salary, housing, transport)"'
label variable D07_01__17 `"(ordered) Achievements: Managment / Administration improved"'
label variable D07_01__18 `"(ordered) Achievements: Number of teachers increased"'
label variable D07_01__19 `"(ordered) Achievements: Parental involvement increased"'
label variable D07_01__20 `"(ordered) Achievements: Contracted cleaning staff"'
label variable D07_01__21 `"(ordered) Achievements: Contracted security staff"'
label variable D07_01__22 `"(ordered) Achievements: New school under construction"'
label variable D07_01__23 `"(ordered) Achievements: Water / electicity improvements"'

drop D07_01__0 D07_01__999 D07_01_other D07_01__20_old

rename D07_02__31 D07_02__31_old

gen D07_02__31 = 0 if D07_02__1!=.
gen D07_02__32 = 0 if D07_02__1!=.
gen D07_02__33 = 0 if D07_02__1!=.
gen D07_02__34 = 0 if D07_02__1!=.

order D07_02__31 D07_02__32 D07_02__33 D07_02__34, after(D07_02__30)

replace D07_02__2 = D07_02__31_old if D07_02_other=="Falta de casa de recadacão, construção de mais salas de aula" & D07_02__2 == 0
replace D07_02__3 = D07_02__31_old if D07_02_other=="Falta de professor" & D07_02__3 == 0
replace D07_02__3 = D07_02__31_old if D07_02_other=="Falta de Professores" & D07_02__3 == 0
replace D07_02__3 = D07_02__31_old if D07_02_other=="desabamento da escola, falta de professores" & D07_02__3 == 0
replace D07_02__3 = D07_02__31_old if D07_02_other=="Desabamento dás salas de aula anexa da maria ganza, falta de professor" & D07_02__3 == 0
replace D07_02__4 = D07_02__31_old if D07_02_other=="Desabamento dás salas de aula anexa da maria ganza, falta de professor" & D07_02__4 == 0
replace D07_02__4 = D07_02__31_old if D07_02_other=="desabamento da escola, falta de professores" & D07_02__4 == 0
replace D07_02__4 = D07_02__31_old if D07_02_other=="Devido o remoinho de vento as chapas destamparam" & D07_02__4 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="área de lazer" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Falta da Vedação da Escola" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="falta de casas parae professores" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Falta de Residência para Professores" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Falta de vedação" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Falta de vedação" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Falta de vedação" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Organização da sala dos Professores" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="residências para os professores" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Sala de arrecadação, e melhorar a vedação" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Vedação do muro" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Falta de casa de recadacão, construção de mais salas de aula" & D07_02__6 == 0
replace D07_02__6 = D07_02__31_old if D07_02_other=="Fakta de transporte, sala para professores, materias informáticos" & D07_02__6 == 0
replace D07_02__8 = D07_02__31_old if D07_02_other=="atraso por parte dos aluno e professores" & D07_02__8 == 0
replace D07_02__15 = D07_02__31_old if D07_02_other=="Dificuldades na aplicação da avaliação das aprendizagem dos alunos" & D07_02__15 == 0
replace D07_02__18 = D07_02__31_old if D07_02_other=="insatisfação do salário de cargo de direção" & D07_02__18 == 0
replace D07_02__19 = D07_02__31_old if D07_02_other=="indisciplina de um dos professores" & D07_02__19 == 0
replace D07_02__26 = D07_02__31_old if D07_02_other=="Falta de Carteiras" & D07_02__26 == 0
replace D07_02__27 = D07_02__31_old if D07_02_other=="material de desportos" & D07_02__27 == 0
replace D07_02__27 = D07_02__31_old if D07_02_other=="Fakta de transporte, sala para professores, materias informáticos" & D07_02__27 == 0
replace D07_02__27 = D07_02__31_old if D07_02_other=="Computador, e Impressora." & D07_02__27 == 0
replace D07_02__27 = D07_02__31_old if D07_02_other=="Computadores" & D07_02__27 == 0
replace D07_02__27 = D07_02__31_old if D07_02_other=="Falta de computadores para trabalhos Administrativos" & D07_02__27 == 0
replace D07_02__28 = D07_02__31_old if D07_02_other=="Vandalismo e Falta de transporte p/professores" & D07_02__28 == 0
replace D07_02__31 = D07_02__31_old if D07_02_other=="falta de merenda escolar" & D07_02__31 == 0
replace D07_02__31 = D07_02__31_old if D07_02_other=="falta de merenda escolar" & D07_02__31 == 0
replace D07_02__31 = D07_02__31_old if D07_02_other=="Falta de merenda escolar" & D07_02__31 == 0
replace D07_02__31 = D07_02__31_old if D07_02_other=="Merenda escolar" & D07_02__31 == 0
replace D07_02__31 = D07_02__31_old if D07_02_other=="Degradação da Escola, Falta de merenda escolar" & D07_02__31 == 0
replace D07_02__31 = D07_02__31_old if D07_02_other=="Degradação da Escola, Falta de merenda escolar" & D07_02__31 == 0
replace D07_02__32 = D07_02__31_old if D07_02_other=="Vandalismo e Falta de transporte p/professores" & D07_02__32 == 0
replace D07_02__32 = D07_02__31_old if D07_02_other=="Aproximação ao mercado" & D07_02__32 == 0
replace D07_02__32 = D07_02__31_old if D07_02_other=="Falta de transporte escolar" & D07_02__32 == 0
replace D07_02__32 = D07_02__31_old if D07_02_other=="Falta de transporte para deslocar-se  a sede da Quibala" & D07_02__32 == 0
replace D07_02__32 = D07_02__31_old if D07_02_other=="localização" & D07_02__32 == 0
replace D07_02__32 = D07_02__31_old if D07_02_other=="Transporte para os professores; Falta de meio para o transporte do material escolar" & D07_02__32 == 0
replace D07_02__32 = D07_02__31_old if D07_02_other=="Fakta de transporte, sala para professores, materias informáticos" & D07_02__32 == 0
replace D07_02__34 = D07_02__31_old if D07_02_other=="Falta de auxiliar de limpeza" & D07_02__34 == 0

label variable D07_02__1 `"(ordered) Problem: Too many students per class"'
label variable D07_02__2 `"(ordered) Problem: Not enough classrooms"'
label variable D07_02__3 `"(ordered) Problem: Not enough teachers"'
label variable D07_02__4 `"(ordered) Problem: Low quality of the classrooms (school in general)"'
label variable D07_02__5 `"(ordered) Problem: Low quality or missing bathrooms"'
label variable D07_02__6 `"(ordered) Problem: Low quality or missing other facilities"'
label variable D07_02__7 `"(ordered) Problem: Weak health of students"'
label variable D07_02__8 `"(ordered) Problem: Students not complying with the schedule"'
label variable D07_02__9 `"(ordered) Problem: Student absence"'
label variable D07_02__10 `"(ordered) Problem: High drop out rate of students"'
label variable D07_02__11 `"(ordered) Problem: Misconduct and physical conflicts between students"'
label variable D07_02__12 `"(ordered) Problem: Student empathy towards teachers"'
label variable D07_02__13 `"(ordered) Problem: Students disrespect towards teachers"'
label variable D07_02__14 `"(ordered) Problem: Lack of parent involvement"'
label variable D07_02__15 `"(ordered) Problem: Unpreparedness of school team"'
label variable D07_02__16 `"(ordered) Problem: Teachers not complying with the schedule"'
label variable D07_02__17 `"(ordered) Problem: Teacher absence"'
label variable D07_02__18 `"(ordered) Problem: Low teacher salary"'
label variable D07_02__19 `"(ordered) Problem: Low teacher performance"'
label variable D07_02__20 `"(ordered) Problem: Low teacher motivation"'
label variable D07_02__21 `"(ordered) Problem: Too small school budget"'
label variable D07_02__22 `"(ordered) Problem: Teachers give private classes"'
label variable D07_02__23 `"(ordered) Problem: High cost of school material"'
label variable D07_02__24 `"(ordered) Problem: Automatic transition to higher class in the end of the year"'
label variable D07_02__25 `"(ordered) Problem: Lack of extracurricular activities"'
label variable D07_02__26 `"(ordered) Problem: Lack of furniture"'
label variable D07_02__27 `"(ordered) Problem: Lack of school material"'
label variable D07_02__28 `"(ordered) Problem: Lack of security"'
label variable D07_02__29 `"(ordered) Problem: Lack of electricity and light"'
label variable D07_02__30 `"(ordered) Problem: Lack of water"'
label variable D07_02__31 `"(ordered) Problem: Lack of school meal"'
label variable D07_02__32 `"(ordered) Problem: School location (distance / no transport)"'
label variable D07_02__33 `"(ordered) Problem: School fee"'
label variable D07_02__34 `"(ordered) Problem: Lack of cleaning staff"'

drop D07_02__0 D07_02__31_old D07_02__999 D07_02_other

rename D07_33 D07_33_old

gen D07_33 = 0 if D07_33_old!=.
gen D07_34 = 0 if D07_33_old!=.
gen D07_35 = 0 if D07_33_old!=.

order D07_33 D07_34 D07_35, after(D07_32)

replace D07_05 = 2 if D07_05==0 & D07_33_problem=="Falta de Professor"
replace D07_06 = 2 if D07_06==0 & D07_33_problem=="Falta de janelas e carteiras na escola , e mobilia do gabinete da escola"
replace D07_06 = 2 if D07_06==0 & D07_33_problem=="Falta de manutenção da escola"
replace D07_06 = 2 if D07_06==0 & D07_33_problem=="problema n tetu quando cai chuva."
replace D07_07 = 2 if D07_07==0 & D07_33_problem=="Falta de educação sanitário por parte dos alunos"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Acesso à escola nas épocas chuvosas"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="falta de campo para educação física"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Falta de passadeira e o mau estado do acesso a escola"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Falta de Sala dos Professores, Sala de Arrecadação"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Falta de salas de aulas e residências para professores"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="falta de vedação"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Falta de Vedação"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Falta de material desportivo e musical e uma sala de informática"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Falta de campo multi uso, balneários e merenda escolar"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Falta de janelas e carteiras na escola , e mobilia do gabinete da escola"
replace D07_08 = 2 if D07_08==0 & D07_33_problem=="Faltabde um posto médico"
replace D07_16 = 2 if D07_16==0 & D07_33_problem=="falta de envolvimento dos pais"
replace D07_29 = 2 if D07_29==0 & D07_33_problem=="Falta de material desportivo e musical e uma sala de informática"
replace D07_29 = 2 if D07_29==0 & D07_33_problem=="Falta de materiais Informáticos;( computadores)"
replace D07_30 = 2 if D07_30==0 & D07_33_problem=="Arrombamentos na escola"
replace D07_33 = 2 if D07_33==0 & D07_33_problem=="Falta de campo multi uso, balneários e merenda escolar"
replace D07_33 = 2 if D07_33==0 & D07_33_problem=="Falta de Merenda Escolar"
replace D07_34 = 2 if D07_34==0 & D07_33_problem=="Falta de transporte"
replace D07_34 = 2 if D07_34==0 & D07_33_problem=="falta de transporte"
replace D07_35 = 2 if D07_35==0 & D07_33_problem=="Falta de auxiliar de limpeza"
replace D07_35 = 2 if D07_35==0 & D07_33_problem=="Falta de Auxiliar de limpeza"

label variable D07_03 `"Problem: Too many students per class"'
label variable D07_04 `"Problem: Not enough classrooms"'
label variable D07_05 `"Problem: Not enough teachers"'
label variable D07_06 `"Problem: Low quality of the classrooms"'
label variable D07_07 `"Problem: Low quality or missing bathrooms"'
label variable D07_08 `"Problem: Low quality or missing other facilities"'
label variable D07_09 `"Problem: Weak health of students"'
label variable D07_10 `"Problem: Students not complying with the schedule"'
label variable D07_11 `"Problem: Student absence"'
label variable D07_12 `"Problem: High drop out rate of students"'
label variable D07_13 `"Problem: Misconduct and physical conflicts between students"'
label variable D07_14 `"Problem: Student empathy towards teachers"'
label variable D07_15 `"Problem: Students disrespect towards teachers"'
label variable D07_16 `"Problem: Lack of parent involvement"'
label variable D07_17 `"Problem: Unpreparedness of school team"'
label variable D07_18 `"Problem: Teachers not complying with the schedule"'
label variable D07_19 `"Problem: Teacher absence"'
label variable D07_20 `"Problem: Low teacher salary"'
label variable D07_21 `"Problem: Low teacher performance"'
label variable D07_22 `"Problem: Low teacher motivation"'
label variable D07_23 `"Problem: Too small school budget"'
label variable D07_24 `"Problem: Teachers give private classes"'
label variable D07_25 `"Problem: High cost of school material"'
label variable D07_26 `"Problem: Automatic transition to higher class in the end of the year"'
label variable D07_27 `"Problem: Lack of extracurricular activities"'
label variable D07_28 `"Problem: Lack of furniture"'
label variable D07_29 `"Problem: Lack of school material"'
label variable D07_30 `"Problem: Lack of security"'
label variable D07_31 `"Problem: Lack of electricity and light"'
label variable D07_32 `"Problem: Lack of water"'
label variable D07_33 `"Problem: Lack of school meal"'
label variable D07_34 `"Problem: School location (distance / no transport)"'
label variable D07_35 `"Problem: Lack of cleaning staff"'

drop D07_33_old D07_33_problem

lab val D07_03 D07_04 D07_05 D07_06 D07_07 D07_08 D07_09 D07_10 D07_11 		///
		D07_12 D07_13 D07_14 D07_15 D07_16 D07_17 D07_18 D07_19 D07_20 		///
		D07_21 D07_22 D07_23 D07_24 D07_25 D07_26 D07_27 D07_28 D07_29 		///
		D07_30 D07_31 D07_32 D07_33 D07_34 D07_35 problem


********************************************************************************

********************************************************************************

* Section 8 (P5 / T6 / D8)

rename D08_01__18 D08_01__18_old

gen D08_01__18 = 0 if D08_01__18_old!=.

order D08_01__18, after(D08_01__17)

replace D08_01__2 = D08_01__18_old if D08_01_other=="apetrechamento mobiliário" & D08_01__2 == 0
replace D08_01__2 = D08_01__18_old if D08_01_other=="Compra de fechaduras" & D08_01__2 == 0
replace D08_01__2 = D08_01__18_old if D08_01_other=="Facilitar o acesso aos alunos nas épocas chuvosas; Portas e janelas" & D08_01__2 == 0
replace D08_01__2 = D08_01__18_old if D08_01_other=="Manutenção geral da escola" & D08_01__2 == 0
replace D08_01__2 = D08_01__18_old if D08_01_other=="Melhoramento das salas anexas" & D08_01__2 == 0
replace D08_01__2 = D08_01__18_old if D08_01_other=="Melhoria da escola" & D08_01__2 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="alojamento" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="Cantina Escolar" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="Cantina escolar" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="Compra de materiais informáticos" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="compra de material de educação física,escolar e mosical," & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="Compra de meios datilógrafo e informáticos" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="construção de campo para actividades escolar" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="Construção de casas para os professor" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="construção de sala dos professores" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="Ter uma lavra e cantina escolar" & D08_01__4 == 0
replace D08_01__4 = D08_01__18_old if D08_01_other=="Vedação do Muro" & D08_01__4 == 0
replace D08_01__5 = D08_01__18_old if D08_01_other=="Canalizar água" & D08_01__5 == 0
replace D08_01__5 = D08_01__18_old if D08_01_other=="Construção de um tanque de água" & D08_01__5 == 0
replace D08_01__5 = D08_01__18_old if D08_01_other=="meteria agua na escola e casa de arrecadação" & D08_01__5 == 0
replace D08_01__6 = D08_01__18_old if D08_01_other=="Carteiras para os aluno" & D08_01__6 == 0
replace D08_01__6 = D08_01__18_old if D08_01_other=="Compra de um gerador, e uma copiadora" & D08_01__6 == 0
replace D08_01__7 = D08_01__18_old if D08_01_other=="Compra de computador" & D08_01__7 == 0
replace D08_01__7 = D08_01__18_old if D08_01_other=="Compra de Computadores Administrativo" & D08_01__7 == 0
replace D08_01__7 = D08_01__18_old if D08_01_other=="Compra de computadores para a escola" & D08_01__7 == 0
replace D08_01__7 = D08_01__18_old if D08_01_other=="compra de meios didaticos pedagojico, informatico, equizição de primeiro socorro" & D08_01__7 == 0
replace D08_01__7 = D08_01__18_old if D08_01_other=="Equipamentos informáticos" & D08_01__7 == 0
replace D08_01__9 = D08_01__18_old if D08_01_other=="Merenda escolar" & D08_01__9 == 0

label variable D08_01__1 `"Budget priorities: Build new school"'
label variable D08_01__2 `"Budget priorities: Build/improve classrooms"'
label variable D08_01__3 `"Budget priorities: Build/improve bathrooms"'
label variable D08_01__4 `"Budget priorities: Build/improve other facilities"'
label variable D08_01__5 `"Budget priorities: Build/improve water/electricity"'
label variable D08_01__6 `"Budget priorities: Buy/maintain furniture"'
label variable D08_01__7 `"Budget priorities: Buy school material"'
label variable D08_01__8 `"Budget priorities: Increase the number class periods"'
label variable D08_01__9 `"Budget priorities: Provide school meals"'
label variable D08_01__10 `"Budget priorities: Organize extracuricular activities"'
label variable D08_01__11 `"Budget priorities: Contract more teachers"'
label variable D08_01__12 `"Budget priorities: Increase teacher salary"'
label variable D08_01__13 `"Budget priorities: Invest in teacher education"'
label variable D08_01__14 `"Budget priorities: Contract security staff"'
label variable D08_01__15 `"Budget priorities: Contract cleaning staff"'
label variable D08_01__16 `"Budget priorities: Increase the number of classes"'
label variable D08_01__17 `"Budget priorities: Arrange transport"'
label variable D08_01__18 `"Budget priorities: Save the money"'

drop D08_01__18_old D08_01__999 D08_01_other


********************************************************************************

********************************************************************************

* Section 8 (P6 / T7 / D8)

// labelssss

#delimit ;
;
label define agree
1 `"Agree a lot"'
2 `"Agree"'
3 `"Do not agree nor disagree"'
4 `"Disagree"'
5 `"Disagree a lot"'
;
label define satisfied
1 `"Very satisfied"'
2 `"Satisfied"'
3 `"Dissatisfied"'
4 `"Very dissatisfied"'
;
#delimit cr

foreach var in 	D09_01 D09_02 D09_03 D09_04 D09_05 D09_06 D09_07 D09_08 	///
				D09_09 D09_10 D09_11 D09_12 {
	replace `var' = . if `var'==999
}

lab val D09_01 D09_02 D09_03 D09_04 D09_05 D09_06 agree
lab val D09_07 D09_08 D09_09 D09_10 good
lab val D09_11 D09_12 satisfied

label variable D09_01 `"Agree or disagree: Teacher motivation is high"'
label variable D09_02 `"Agree or disagree: Teachers take their responsibility very serious"'
label variable D09_03 `"Agree or disagree: Directors take their responsibilities very serious"'
label variable D09_04 `"Agree or disagree: Parent involvement is high"'
label variable D09_05 `"Agree or disagree: Parents always available to help with extra activities"'
label variable D09_06 `"Agree or disagree: School works well for future students"'
label variable D09_07 `"Performance evaluation: school board"'
label variable D09_08 `"Performance evaluation: teachers"'
label variable D09_09 `"Performance evaluation: school team in general"'
label variable D09_10 `"Performance evaluation: parent committee"'
label variable D09_11 `"Satisfaction with respect to salary"'
label variable D09_12 `"Satisfaction with respect to career"'

********************************************************************************

********************************************************************************


* Section 10 (P7 / T8 / D10)

// labelssss

#delimit ;
;
label define freq2
1 `"Very often"'
2 `"Often"'
3 `"Sometimes"'
4 `"Rare"'
5 `"Does not happen"'
;
#delimit cr

foreach var in  D10_01_01 D10_01_01_value D10_01_02 D10_01_02_value 		///
	D10_01_03 D10_01_01_hours D10_02 D10_03 D10_04 D10_05 D10_06 D10_07{
replace `var' = . if inlist(`var',999,-999999999)
}

lab val D10_01_01 D10_01_02 D10_01_03 D10_07 D10_09 dummy
lab val D10_02 D10_03 D10_04 D10_05 D10_06 freq2

label variable D10_01_01 `"Received money from parent"'
label variable D10_01_01_value `"Value money received from parent"'
label variable D10_01_02 `"Received gift from parent"'
label variable D10_01_02_value `"Value gifts received from parent"'
label variable D10_01_03 `"Received service from parent"'
label variable D10_01_01_hours `"Hours service received from parent"'

label variable D10_02 `"Frequency: Parent asks teacher to give private classes"'
label variable D10_03 `"Frequency: Teacher gives private classes"'
label variable D10_04 `"Frequency: Parents bribe teachers"'
label variable D10_05 `"Frequency: Misappropriation of school funds"'
label variable D10_06 `"Frequency: Directors and teachers get jobs because of personal relations"'

label variable D10_07 `"Made complaint or suggestion"'

label variable D10_08__1 `"Way of complain or suggestion: Talk to school director"'
label variable D10_08__2 `"Way of complain or suggestion: Talk to school board"'
label variable D10_08__3 `"Way of complain or suggestion: Talk to teacher of child"'
label variable D10_08__4 `"Way of complain or suggestion: Talk to other staff of the school"'
label variable D10_08__5 `"Way of complain or suggestion: Left a complaint in a complaint box of a public organization"'
label variable D10_08__6 `"Way of complain or suggestion: Via the comunal/municipal board"'
label variable D10_08__7 `"Way of complain or suggestion: At a forum for community representatives"'
label variable D10_08__8 `"Way of complain or suggestion: Via media (news papers, radio, tv"'
label variable D10_08__9 `"Way of complain or suggestion: Via a forum for NGOs"'
label variable D10_08__10 `"Way of complain or suggestion: Via a forum at the community/church"'

replace D10_08__6 = 1 if D10_08_other=="No homem da inspeção"
replace D10_08__6 = 1 if D10_08_other=="Falou com o chefe da Repartição Municipal da Educação"
replace D10_08__6 = 1 if D10_08_other=="com coordenador de zona"
replace D10_08__4 = 1 if D10_08_other=="No conselho consultivo"

drop D10_08__11 D10_08__999 D10_08_other

label variable D10_09 `"Are there (other) ways to complain or make suggestions?"'
label variable D10_10__1 `"(Other) way of complain or suggestion: Talk to school director"'
label variable D10_10__2 `"(Other) way of complain or suggestion: Talk to school board"'
label variable D10_10__3 `"(Other) way of complain or suggestion: Talk to teacher of child"'
label variable D10_10__4 `"(Other) way of complain or suggestion: Talk to other staff of the school"'
label variable D10_10__5 `"(Other) way of complain or suggestion: Left a complaint in a complaint box of a public organization"'
label variable D10_10__6 `"(Other) way of complain or suggestion: Via the comunal/municipal board"'
label variable D10_10__7 `"(Other) way of complain or suggestion: At a forum for community representatives"'
label variable D10_10__8 `"(Other) way of complain or suggestion: Via media (news papers, radio, tv"'
label variable D10_10__9 `"(Other) way of complain or suggestion: Via a forum for NGOs"'
label variable D10_10__10 `"(Other) way of complain or suggestion: Via a forum at the community/church"'

replace D10_10__6 = 1 if D10_10_other=="marcar audiência com o chefe da repartição"
replace D10_10__6 = 1 if D10_10_other=="fazer uma e enviar a coordenação municipal"
replace D10_10__6 = 1 if D10_10_other=="Carta escrita para repartição municipal"
replace D10_10__4 = 1 if D10_10_other=="Comissão de pais"
replace D10_10__6 = 1 if D10_10_other=="Administração Municipal"
replace D10_10__6 = 1 if D10_10_other=="Nos encontros com a repartição aprovita-se fazer criticas ou sugestões"
replace D10_10__6 = 1 if D10_10_other=="fazer um documento e enviar a repartição municipal"
replace D10_10__1 = 1 if D10_10_other=="Conversa com o mesmo professor ou director"

lab val D10_08__1 D10_08__2 D10_08__3 D10_08__4 D10_08__5 D10_08__6 		///
		D10_08__7 D10_08__8 D10_08__9 D10_08__10 D10_10__1 D10_10__2 		///
		D10_10__3 D10_10__4 D10_10__5 D10_10__6 D10_10__7 D10_10__8 		///
		D10_10__9 D10_10__10 dummy

drop D10_10__11 D10_10__999 D10_10_other

********************************************************************************

********************************************************************************

* Section 11 (P8 / T9 / D11)

foreach var in  D11_01 D11_02 D11_03 D11_04 D11_05{
replace `var' = . if inlist(`var',999,-999999999)
}

// labelssss

#delimit ;
;
label define D11_04
0 `"Muito alto"'
1 `"Muito baixo"'
;
label define D11_05
0 `"No, you have to be carefull"'
1 `"Yes, others are trustworthy"'
;
#delimit cr

lab val D11_01 D11_02 D11_03 agree

label variable D11_01 `"Agree or disagree: Parents do not understand the benefits of education"'
label variable D11_02 `"Agree or disagree: Education gives an advantage to my children"'
label variable D11_03 `"Agree or disagree: Teachers get a fair salary"'
label values D11_04 D11_04
label variable D11_04 `"Disagree with fair salary statement because teacher salary is too low"'
label variable D11_05 `"Others are trustworthy"'
recode D11_05 (1=0) (0=1)
label values D11_05 D11_05

********************************************************************************

********************************************************************************

* Section 12 (P9 / T10 / D12)

label values D12_01 dummy
label variable D12_01 `"Member of club, social organisation or church"'

label variable D12_02 `"Number of social groups"'

********************************************************************************

save "$Endline_dtRaw/_intermediate files/director.dta", replace

********************************************************************************

* add roster D12

use "$Endline_dtRaw/director/D12_roster.dta", clear

label drop _all

********************************************************************************

drop if inlist(interview__key,"29-35-82-40","45-38-73-05","24-37-82-64")

********************************************************************************

drop interview__id
rename interview__key 	ss_key
rename D12_roster__id roster_id_D12

/// labels

#delimit ;
;
label define dummy
0	"No"
1 	"Yes"
;
label define D12_04
1 `"Association for farmers/fishermen"'
2 `"Association for small business/traders"'
3 `"Association related to a profession (e.g. doctors, teachers)"'
4 `"Chamber of Commerce"'
5 `"Religious group"'
6 `"Political movement"'
7 `"Cultural association"'
8 `"Sport club"'
9 `"NGO"'
10 `"Credit club (kixikila)"'
11 `"Group based on ethnicity"'
;
#delimit cr

foreach var in  D12_04 D12_05 D12_06{
replace `var' = . if inlist(`var',999,-999999999)
}


label variable D12_03 `"Name of organisation"'
label values D12_04 D12_04
label variable D12_04 `"Type of organisation"'
label variable D12_05 `"Number of local members of organisation"'
label values D12_06 dummy
label variable D12_06 `"Respondent is a leader within the organisation"'

drop D12_04_other

foreach var in D12_03 D12_04 D12_05 D12_06{
rename `var' `var'_
}
reshape wide D12_03_ D12_04_ D12_05_ D12_06_, i(ss_key) j(roster_id_D12)

forval x = 1/3{
lab var D12_03_`x' "(`x') Name of organisation"
lab var D12_04_`x' "(`x') Type of organisation"
lab var D12_05_`x' "(`x') Number of local members of organisation"
lab var D12_06_`x' "(`x') Respondent is a leader within the organisation"
}

save "$Endline_dtRaw/_intermediate files/director_D12.dta", replace

********************************************************************************

use "$Endline_dtRaw/_intermediate files/director.dta", clear

merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/director_D12.dta"

order 	D12_03_1 D12_04_1 D12_05_1 D12_06_1 D12_03_2 D12_04_2 D12_05_2 		///
		D12_06_2 D12_03_3 D12_04_3 D12_05_3 D12_06_3, after(D12_02)

drop _merge

********************************************************************************

********************************************************************************

* Section 13 (P10 / T11 / D13)

foreach var in  D13_01 D13_02 D13_03 D13_04 D13_04_times D13_05 			///
				D13_05_times D13_06{
replace `var' = . if inlist(`var',999,-999999999)
}


#delimit ;
;
label define D13_03
0 `"Did not contribute"'
1 `"Contributed with time"'
2 `"Contributed with money"'
3 `"Contributed with time and money"'
;
#delimit cr

lab val D13_01 D13_02 agree
lab val D13_04 D13_05 D13_06 dummy

label variable D13_01 `"Agree or disagree: Other people are available to help in necessary"'
label variable D13_02 `"Agree or disagree: Here there are people that try to take advantage of others"'

label values D13_03 D13_03
label variable D13_03 `"Public good contribution with time or money"'

label variable D13_04 `"Participated in community work"'
label variable D13_04_times `"Number of times participated in community work"'
label variable D13_05 `"Gathering to demand improvements from leaders"'
label variable D13_05_times `"Number of times gathering to demand improvements from leaders"'
label variable D13_06 `"Voted in 2017"'

label variable D13_07__1 `"Sources of information about what the government does: Family friends neighbors"'
label variable D13_07__2 `"Sources of information about what the government does: Local newspaper"'
label variable D13_07__3 `"Sources of information about what the government does: Billboard advertisement"'
label variable D13_07__4 `"Sources of information about what the government does: National newspaper"'
label variable D13_07__5 `"Sources of information about what the government does: Radio"'
label variable D13_07__6 `"Sources of information about what the government does: TV"'
label variable D13_07__7 `"Sources of information about what the government does: Group or association"'
label variable D13_07__8 `"Sources of information about what the government does: Business partners and colleague"'
label variable D13_07__9 `"Sources of information about what the government does: Community leaders"'
label variable D13_07__10 `"Sources of information about what the government does: Government representative"'
label variable D13_07__11 `"Sources of information about what the government does: NGO"'
label variable D13_07__12 `"Sources of information about what the government does: Internet (social media)"'

replace D13_07__4 = 1 if D13_07_other=="Diario da república"
replace D13_07__10 = 1 if D13_07_other=="Direção municipal e Provincial de educação."

drop D13_07__13 D13_07__999 D13_07_other

lab val D13_07__1 D13_07__2 D13_07__3 D13_07__4 D13_07__5 D13_07__6 		///
		D13_07__7 D13_07__8 D13_07__9 D13_07__10 D13_07__11 D13_07__12 dummy

********************************************************************************

********************************************************************************

* Section 14 (P11 / T12 / D14)

foreach var in  D14_02_01 D14_03_01 D14_02_02 D14_03_02 D14_02_03 			///
D14_03_03 D14_02_04 D14_03_04 D14_02_05 D14_03_05 D14_02_06 D14_03_06 		///
D14_02_07 D14_03_07 D14_02_08 D14_03_08 D14_02_09 D14_03_09 D14_02_10 		///
D14_03_10 D14_02_11 D14_03_11 D14_02_12 D14_03_12 D14_02_13 D14_03_13 		///
D14_02_14 D14_03_14 D14_02_15 D14_03_15 D14_02_16_measure D14_02_16_01 		///
D14_02_16_02 D14_03_16 D14_02_17 D14_03_17 D14_02_18 D14_03_18 D14_02_19 	///
D14_03_19 D14_02_20 D14_03_20{
replace `var' = . if inlist(`var',999,-999999999)
}

#delimit ;
;
label define D14_02_16_measure
1 `"Hectares"'
2 `"Squared meters"'
;
#delimit cr

lab val D14_01__1 D14_01__2 D14_01__3 D14_01__4 D14_01__5 D14_01__6 		///
		D14_01__7 D14_01__8 D14_01__9 D14_01__10 D14_01__11 D14_01__12 		///
		D14_01__13 D14_01__14 D14_01__15 D14_01__16 D14_01__17 D14_01__18 	///
		D14_01__19 D14_01__20 dummy

label variable D14_01__1 `"Possession in household: Books"'
label variable D14_01__2 `"Possession in household: Radios"'
label variable D14_01__3 `"Possession in household: Televisions"'
label variable D14_01__4 `"Possession in household: Computers"'
label variable D14_01__5 `"Possession in household: Yablets"'
label variable D14_01__6 `"Possession in household: Digital cameras"'
label variable D14_01__7 `"Possession in household: Smartphones"'
label variable D14_01__8 `"Possession in household: Normal phones"'
label variable D14_01__9 `"Possession in household: Bicycles"'
label variable D14_01__10 `"Possession in household: Motor bikes"'
label variable D14_01__11 `"Possession in household: Cars"'
label variable D14_01__12 `"Possession in household: Ovens/microwaves"'
label variable D14_01__13 `"Possession in household: Washing machines"'
label variable D14_01__14 `"Possession in household: Fridges"'
label variable D14_01__15 `"Possession in household: Stoves"'
label variable D14_01__16 `"Possession in household: Land"'
label variable D14_01__17 `"Possession in household: Houses"'
label variable D14_01__18 `"Possession in household: Animals"'
label variable D14_01__19 `"Possession in household: Big agricultural equipment"'
label variable D14_01__20 `"Possession in household: Small agricultural equipment"'

label variable D14_02_01 `"Number of books"'
label variable D14_03_01 `"Value of books"'
label variable D14_02_02 `"Number of radios"'
label variable D14_03_02 `"Value of radios"'
label variable D14_02_03 `"Number of televisions"'
label variable D14_03_03 `"Value of televisions"'
label variable D14_02_04 `"Number of computers"'
label variable D14_03_04 `"Value of computers"'
label variable D14_02_05 `"Number of tablets"'
label variable D14_03_05 `"Value of tablets"'
label variable D14_02_06 `"Number of digital cameras"'
label variable D14_03_06 `"Value of digital cameras"'
label variable D14_02_07 `"Number of smartphones"'
label variable D14_03_07 `"Value of smartphones"'
label variable D14_02_08 `"Number of normal phones"'
label variable D14_03_08 `"Value of normal phones"'
label variable D14_02_09 `"Number of bicycles"'
label variable D14_03_09 `"Value of bicycles"'
label variable D14_02_10 `"Number of motor bikes"'
label variable D14_03_10 `"Value of motor bikes"'
label variable D14_02_11 `"Number of cars"'
label variable D14_03_11 `"Value of cars"'
label variable D14_02_12 `"Number of ovens/microwaves"'
label variable D14_03_12 `"Value of ovens/microwaves"'
label variable D14_02_13 `"Number of washing machines"'
label variable D14_03_13 `"Value of washing machines"'
label variable D14_02_14 `"Number of fridges"'
label variable D14_03_14 `"Value of fridges"'
label variable D14_02_15 `"Number of stoves"'
label variable D14_03_15 `"Value of stoves"'

label values D14_02_16_measure D14_02_16_measure
label variable D14_02_16_measure `"Type of measure: hectares or squared meters"'

label variable D14_02_16_01 `"Size of land"'
label variable D14_02_16_02 `"Size of land"'
label variable D14_03_16 `"Value of land"'
label variable D14_02_17 `"Number of houses"'
label variable D14_03_17 `"Value of houses"'
label variable D14_02_18 `"Number of animals"'
label variable D14_03_18 `"Value of animals"'
label variable D14_02_19 `"Number of big agricultural equipment"'
label variable D14_03_19 `"Value of big agricultural equipment"'
label variable D14_02_20 `"Number of small agricultural equipment"'
label variable D14_03_20 `"Value of small agricultural equipment"'

drop D14_01__999

********************************************************************************

********************************************************************************

* Section 15 (T13 / D15)

label values D15_01 dummy
label variable D15_01 `"Teacher of one of the selected students"'
label variable D15_02 `"Number of selected students"'

replace D15_01 = . if D15_01==-999999999

replace D15_02 = . if D15_01==0


********************************************************************************

save "$Endline_dtRaw/_intermediate files/director.dta", replace

********************************************************************************

* add roster D15 (name D13)

use "$Endline_dtRaw/director/D13_roster.dta", clear

label drop _all

********************************************************************************

drop if inlist(interview__key,"29-35-82-40","45-38-73-05","24-37-82-64")

********************************************************************************

drop interview__id
rename interview__key 	ss_key
rename D13_roster__id roster_id_D15

/// labels

#delimit ;
;
label define agree
1 `"Agree a lot"'
2 `"Agree"'
3 `"Do not agree nor disagree"'
4 `"Disagree"'
5 `"Disagree a lot"'
;
label define D15_13
0 `"Not involved"'
1 `"Very little involved"'
2 `"Little involved"'
3 `"Involved"'
4 `"Very much involved"'
;
label define dummy
0	"No"
1 	"Yes"
;
#delimit cr

foreach var in  D15_03 D15_05 D15_06 D15_08 D15_09 D15_10 D15_11 D15_12 D15_13{
replace `var' = . if inlist(`var',999,-999999999,9999)
}

replace D15_12 = . if D15_12==6
replace D15_13 = . if D15_13==5

label variable D15_03 `"Student selected ID"'
label variable D15_04 `"Student name"'
label values D15_05 dummy
label variable D15_05 `"Student repeating situation"'
label values D15_06 dummy
label variable D15_06 `"Students last year teacher"'
label variable D15_07 `"Last year students teacher"'
label variable D15_08 `"Last year teacher ID"'
label variable D15_09 `"Sent information in the last four weeks to parents"'
label variable D15_10 `"How many times parents were invited for a meeting with teacher"'
label variable D15_11 `"How many times parents came to school to talk to teacher"'
label values D15_12 agree
label variable D15_12 `"Parents and school objective"'
label values D15_13 D15_13
label variable D15_13 `"Parents involvement in students school life"'

foreach var in 	D15_03 D15_04 D15_05 D15_06 D15_07 D15_08 D15_09 D15_10 		///
				D15_11 D15_12 D15_13{
rename `var' `var'_
}

reshape wide 	D15_03_ D15_04_ D15_05_ D15_06_ D15_07_ D15_08_ D15_09_ 	///
				D15_10_ D15_11_ D15_12_ D15_13_, i(ss_key) j(roster_id_D15)

forval x = 1/20{
lab var D15_03_`x' "(`x') Student selected ID"
lab var D15_04_`x' "(`x') Student name"
lab var D15_05_`x' "(`x') Student repeating situation"
lab var D15_06_`x' "(`x') Students last year teacher"
lab var D15_07_`x' "(`x') Last year students teacher"
lab var D15_08_`x' "(`x') Last year teacher ID"
lab var D15_09_`x' "(`x') Sent information in the last four weeks to parents"
lab var D15_10_`x' "(`x') How many times parents were invited for a meeting with teacher"
lab var D15_11_`x' "(`x') How many times parents came to school to talk to teacher"
lab var D15_12_`x' "(`x') Parents and school objective"
lab var D15_13_`x' "(`x') Parents involvement in students school life"
}


save "$Endline_dtRaw/_intermediate files/director_D15.dta", replace

********************************************************************************

use "$Endline_dtRaw/_intermediate files/director.dta", clear

merge 1:1 ss_key using "$Endline_dtRaw/_intermediate files/director_D15.dta"

drop _merge


********************************************************************************

save "$Endline_dtRaw/_intermediate files/director.dta", replace
